-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
86 lines (78 loc) · 2.32 KB
/
webpack.config.js
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
86
'use strict';
const path = require('path');
const HtmlPlugin = require('html-webpack-plugin');
module.exports = function webpackConfigFactory(env) {
const isProduction = env === 'production';
const isDevelopment = !isProduction;
return {
mode: isProduction ? 'production' : 'development',
bail: isProduction,
entry: path.resolve(__dirname, 'src', 'main.jsx'),
output: {
path: path.resolve(__dirname, 'dist'),
filename: isProduction ? 'js/[name].[contenthash:8].js' : 'js/[name].js',
chunkFilename: isProduction ? 'js/[name].[contenthash:8].chunk.js' : 'js/[name].chunk.js',
pathinfo: isDevelopment,
},
resolve: {
extensions: ['.js', '.jsx', '.json'],
},
module: {
strictExportPresence: true,
rules: [
{ parser: { requireEnsure: false } },
{
oneOf: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
cacheDirectory: true,
cacheCompression: false,
},
},
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
sideEffects: true,
},
{
// JavaScript and CSS loaders are declared above.
// HTML and JSON will be loaded with WebPack internal loaders.
// Everything else will be loaded with file-loader.
exclude: /\.(js|css|html|json)/,
use: {
loader: 'file-loader',
options: {
name: 'static/media/[name].[hash:8].[ext]',
},
},
},
// New loaders should come before the file-loader,
// otherwise it will not work.
],
},
],
},
plugins: [
new HtmlPlugin({
template: path.resolve(__dirname, 'public', 'index.html'),
}),
],
devtool: 'source-map',
devServer: {
disableHostCheck: true,
compress: true,
clientLogLevel: 'none',
host: process.env.HOST || '0.0.0.0',
contentBase: path.resolve(__dirname, 'public'),
historyApiFallback: true,
},
watchOptions: {
ignored: /node_modules/,
},
};
};