-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.prod.js
43 lines (41 loc) · 1.16 KB
/
webpack.config.prod.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
import HtmlWebpackPlugin from "html-webpack-plugin";
import MiniCssExtractPlugin from "mini-css-extract-plugin";
import path from "path";
import { fileURLToPath } from "url";
const config = {
mode: "production",
devtool: "source-map",
entry: {
main: "./src/index.js",
vendor: "./src/vendor.js",
},
output: {
// eslint-disable-next-line no-undef
path: path.resolve(fileURLToPath(import.meta.url), "../dist"),
publicPath: "/",
filename: "[name].[contenthash].js",
},
resolve: {
extensions: [".js"],
},
plugins: [
// Extract CSS into separate files
new MiniCssExtractPlugin({
filename: "[name].[contenthash].css",
}),
// Create HTML file that includes reference to bundled JS.
new HtmlWebpackPlugin({
template: "src/index.html",
}),
],
module: {
rules: [
{ test: /\.js$/, exclude: /node_modules/, use: ["babel-loader"] },
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, "css-loader"],
},
],
},
};
export default config;