-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.client.config.js
67 lines (63 loc) · 1.5 KB
/
webpack.client.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
require("dotenv").config();
const path = require("path");
const CompressionPlugin = require("compression-webpack-plugin");
const ManifestPlugin = require("webpack-manifest-plugin");
const PUBLIC_JS_DIR = path.resolve(__dirname, "src/public/js");
const SRC_DIR = path.resolve(__dirname, "src");
const isDevelopment = process.env.NODE_ENV === "development";
const clientConfig = {
mode: isDevelopment ? "development" : "production",
devServer: {
contentBase: "./src/public",
port: 8000
},
entry: {
bundle: ["@babel/polyfill", `${SRC_DIR}/client.js`]
},
output: {
path: PUBLIC_JS_DIR,
filename: isDevelopment ? "[name].js" : "[name].[contenthash].js"
},
module: {
rules: [
{
test: /\.jsx?$/,
use: [
{
loader: "babel-loader"
}
],
include: SRC_DIR
},
{
test: /\.scss$/,
use: [
{
loader: "style-loader"
},
{
loader:
"css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]"
},
{
loader: "sass-loader"
}
]
}
]
},
node: {
fs: "empty"
},
plugins: [
!isDevelopment &&
new CompressionPlugin({
asset: "[path].gz[query]",
algorithm: "gzip",
test: /\.js$|\.css$|\.html$/,
threshold: 10240
}),
!isDevelopment && new ManifestPlugin()
].filter(Boolean)
};
module.exports = clientConfig;