/
webpack.config.dev.js
78 lines (77 loc) · 1.87 KB
/
webpack.config.dev.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
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
const HTMLWebpackPlugin = require("html-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const { join } = require("path");
module.exports = {
mode: process.env.NODE_ENV === "production" ? "production" : "development",
devServer: {
historyApiFallback: true,
port: 3322,
},
devtool: process.env.NODE_ENV === "production" ? false : "source-map",
entry: "./demo/app.js",
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: [
{ loader: "babel-loader" },
{
loader: "eslint-loader",
options: {
emitWarning: true,
failOnWarning: false,
},
},
],
},
{
test: /\.style.js$/,
exclude: /node_modules/,
loader: "stylelint-custom-processor-loader",
options: {
emitWarning: true,
},
},
{
test: /\.(svg|png|gif|jpe?g)$/,
exclude: /node_modules/,
use: [
{
loader: "file-loader",
options: {
name: "[name].[ext]",
},
},
],
},
],
},
plugins: [
new HTMLWebpackPlugin({
template: join(__dirname, "assets/webpack_template.html"),
filename: "index.html",
inject: "body",
}),
process.env.NODE_ENV === "production" && new BundleAnalyzerPlugin(),
].filter(Boolean),
optimization: {
minimize: process.env.NODE_ENV === "production",
minimizer: [
new TerserPlugin({
parallel: true,
terserOptions: {
ecma: 5,
output: {
ascii_only: true,
},
},
}),
],
},
output: {
filename: "[name].bundle.js",
path: join(__dirname, "dist/dev"),
},
};