-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.ts
85 lines (82 loc) · 2.17 KB
/
webpack.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import path from 'path';
import { Configuration } from 'webpack';
import ManifestPlugin from 'webpack-manifest-plugin';
import cssnano from 'cssnano';
import { SERVER_PORT, IS_DEV, WEBPACK_PORT } from './src/server/config/config';
const plugins = [new ManifestPlugin()];
const nodeModulesPath = path.resolve(__dirname, 'node_modules');
const config: Configuration = {
mode: IS_DEV ? 'development' : 'production',
devtool: IS_DEV ? 'inline-source-map' : false,
entry: ['core-js', './src/client/Main'],
output: {
path: path.join(__dirname, 'dist', 'statics'),
filename: `[name]-[hash:8]-bundle.js`,
publicPath: '/statics/',
},
optimization: {
splitChunks: {
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all',
},
},
},
},
module: {
rules: [
{
test: /\.tsx?$/,
loaders: ['babel-loader'],
exclude: [/node_modules/, nodeModulesPath],
},
{
test: /\.css$/,
use: [
{
loader: 'style-loader',
},
{
loader: 'css-loader',
options: {
modules: true,
localsConvention: 'camelCase',
sourceMap: IS_DEV,
},
},
{
loader: 'postcss-loader',
options: {
sourceMap: IS_DEV,
plugins: IS_DEV ? [cssnano()] : [],
},
},
],
},
{
test: /.jpe?g$|.gif$|.png$|.svg$|.woff$|.woff2$|.ttf$|.eot$/,
use: 'url-loader?limit=10000',
},
],
},
devServer: {
port: WEBPACK_PORT,
open: false,
openPage: `http://localhost:${SERVER_PORT}`
},
resolve: {
extensions: ['.webpack.js', '.web.js', '.ts', '.tsx', '.js', '.gql', '.graphql', '.json']
},
watchOptions: {
//IN ORDER TO MAKE WEBPACK POLLING WORK WITH WSL ADD 'WEBPACK__WATCH__USE_POLLING=true' IN .env AT ROOT OF PROJECT
poll: JSON.stringify(process.env.WEBPACK__WATCH__USE_POLLING) != null ? true : false,
},
plugins,
externals: {
'react': 'React',
'react-dom': 'ReactDOM',
},
};
export default config;