-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.prod.js
54 lines (51 loc) · 1.36 KB
/
webpack.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
44
45
46
47
48
49
50
51
52
53
54
const merge = require("webpack-merge")
const baseConfig = require("./webpack.base.js")
const webpack = require("webpack")
const path = require("path")
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
const CleanWebpackPlugin = require("clean-webpack-plugin")
const CopyWebpackPlugin = require("copy-webpack-plugin")
const AssetsPlugin = require("assets-webpack-plugin")
const assetsPluginInstance = new AssetsPlugin()
const config = {
mode: "production",
entry: ["@babel/polyfill", "./assets/app.jsx", "./assets/app.scss"],
output: {
filename: "bundle.[chunkhash].js",
path: path.resolve(__dirname, "public"),
},
plugins: [
new CleanWebpackPlugin(["public"]),
new CopyWebpackPlugin([
{
from: "assets/app.scss",
to: "app.scss",
},
]),
new MiniCssExtractPlugin({
filename: "[name].[contenthash].css",
chunkFilename: "[id].css",
}),
new webpack.DefinePlugin({
"process.env.NODE_ENV": JSON.stringify("production"),
}),
assetsPluginInstance,
],
module: {
rules: [
{
include: [path.resolve("node_modules")],
sideEffects: false,
},
{
test: /\.(sass|scss)$/,
use: [
MiniCssExtractPlugin.loader,
"css-loader",
"sass-loader",
],
},
],
},
}
module.exports = merge(baseConfig, config)