forked from unpkg/unpkg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
48 lines (41 loc) · 1.17 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
const path = require("path");
const webpack = require("webpack");
const MiniCSSExtractPlugin = require("mini-css-extract-plugin");
module.exports = {
mode: process.env.NODE_ENV || "development",
entry: {
main: path.resolve(__dirname, "./modules/client/main.js"),
autoIndex: path.resolve(__dirname, "./modules/client/autoIndex.js")
},
externals: {
react: "React",
"react-dom": "ReactDOM",
"react-router-dom": "ReactRouterDOM"
},
output: {
filename: "[name]-[hash:8].js",
path: path.resolve(__dirname, "public/_assets"),
publicPath: "/_assets/"
},
module: {
rules: [
{ test: /\.js$/, exclude: /node_modules/, use: "babel-loader" },
{
test: /\.css$/,
use: [MiniCSSExtractPlugin.loader, "css-loader"]
},
{ test: /\.md$/, use: ["html-loader", "markdown-loader"] },
{ test: /\.png$/, use: "file-loader" }
]
},
plugins: [
new webpack.DefinePlugin({
"process.env.NODE_ENV": JSON.stringify(
process.env.NODE_ENV || "development"
)
}),
new MiniCSSExtractPlugin()
],
devtool:
process.env.NODE_ENV === "production" ? false : "cheap-module-source-map"
};