-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.client.js
executable file
·45 lines (41 loc) · 1.12 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
const path = require("path");
const webpack = require("webpack");
const { ReactLoadablePlugin } = require("react-loadable/webpack");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const developmentMode = process.env.NODE_ENV === "development";
const webpackConfigClient = {
mode: developmentMode ? "development" : "production",
entry: {
app: ["./client/index.js"]
},
module: {
rules: [{ test: /\.js$/, exclude: /node_modules/, loader: "babel-loader" }]
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "client.bundle.js",
chunkFilename: "[name].chunk.js"
},
plugins: [
new webpack.ProvidePlugin({
React: "react"
}),
new ReactLoadablePlugin({
filename: "./dist/react-loadable.json"
}),
new CopyWebpackPlugin([
{
from: "./client/static",
to: "static"
}
])
]
};
if (developmentMode) {
webpackConfigClient.entry.app.unshift(
"react-hot-loader/patch",
"webpack-hot-middleware/client"
);
webpackConfigClient.plugins.push(new webpack.HotModuleReplacementPlugin());
}
module.exports = webpackConfigClient;