-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
67 lines (66 loc) · 1.83 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
module.exports = {
// The file that is the main point of access for the SPA
entry: path.join(__dirname, "src/client.js"),
// Where you want to output the file
output: {
// The output file's name
filename: "bundle.js",
// Where the output JavaScript bundle will go
path: path.join(__dirname, "build")
},
// The mode to determine what optimizations to make
mode: "development",
// The source map tool to see where errors occur in your editor
devtool: "cheap-module-source-map",
// The loaders which handle how to compile which files
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules)/,
use: {
loader: "babel-loader",
options: {
presets: ["@babel/preset-env", "@babel/preset-react"]
}
}
},
{
test: /\.css$/,
use: [{ loader: "style-loader" }, { loader: "css-loader" }]
},
{
test: /\.html$/,
use: [
{
loader: "html-loader"
}
]
}
]
},
plugins: [
// Plugin to clean the build folder on every build
new CleanWebpackPlugin(),
// Plugin to create the index.html file and inject the script which
// points to the JavaScript bundle
new HtmlWebpackPlugin({
template: path.join(__dirname, "src/index.html"),
filename: "index.html"
})
],
// The development server
devServer: {
// The path to the output folder to serve
contentBase: path.join(__dirname, "../dist"),
// Fallback to index.html on 404s
historyApiFallback: true,
// Enable gzip compression
compress: true,
// Declare the port to serve the files
port: 3000
}
};