-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.client.js
55 lines (54 loc) · 1.37 KB
/
webpack.client.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
const path = require("path");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const { ReactLoadablePlugin } = require("react-loadable/webpack");
const ManifestPlugin = require("webpack-manifest-plugin");
const shellPlugin = require("webpack-shell-plugin");
module.exports = {
mode: "development",
target: "web",
entry: "./src/client/index.js",
output: {
path: path.join(__dirname, "public"),
filename: "[name].[hash].js",
publicPath: "/",
chunkFilename: "[name].[hash].js"
},
module: {
rules: [
{
test: /\.js$/,
use: "babel-loader",
exclude: /node_modules/
},
{
test: /\.(sa|sc|c)ss$/,
loaders: [
"style-loader", // inject CSS to the page
"css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]", // translates CSS into CommonJS modules
"sass-loader"
]
}
]
},
plugins: [
new CleanWebpackPlugin(["public"]),
new ReactLoadablePlugin({
filename: "./public/react-loadable.json"
}),
new ManifestPlugin(),
new shellPlugin({
onBuildEnd: ["webpack --config webpack.server.js --watch"]
})
],
optimization: {
splitChunks: {
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]/,
name: "vendors",
chunks: "all"
}
}
}
}
};