-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
82 lines (66 loc) · 2.05 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
var webpack = require("webpack"),
path = require('path'),
TerserPlugin = require("terser-webpack-plugin");
const isProduction = (process.env.NODE_ENV === 'production');
console.log("process.env.NODE_ENV: ", process.env.NODE_ENV);
console.log("isProduction: ", isProduction);
const config = {
// https://webpack.js.org/concepts/#mode
mode: isProduction ? "production" : "development",
// https://webpack.js.org/configuration/devtool/
devtool: !isProduction ? "eval-source-map" : false,
devServer: {
contentBase: path.resolve(__dirname, 'public'),
},
entry: {
"index" : path.resolve(__dirname, 'scripts/index'),
// "serviceworker" : path.resolve(__dirname, 'scripts/serviceworker'),
},
output: {
path: path.resolve(__dirname, 'public/assets'),
publicPath: '/assets/',
filename: "[name].mjs",
clean: true
},
optimization: {
chunkIds: 'named',
minimize: true,
minimizer: [new TerserPlugin({
terserOptions: {
compress: {
drop_console: true
}
}
})],
},
module: {
rules: [
{
test: /\.(m?js|jsx)$/,
exclude: /node_modules/,
use: 'babel-loader'
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader']
},{
test: /\.scss$/,
use: [ 'style-loader', 'css-loader', 'sass-loader'],
},
{
test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)$/i,
// More information here https://webpack.js.org/guides/asset-modules/
type: 'asset/resource'
}
],
},
resolve: {
extensions: ['.js', '.jsx', '.mjs'],
modules: [
path.resolve(__dirname, 'scripts'),
path.resolve(__dirname, 'styles'),
path.resolve(__dirname, 'node_modules')
]
}
};
module.exports = config;