-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathwebpack.config.js
More file actions
116 lines (113 loc) · 2.79 KB
/
webpack.config.js
File metadata and controls
116 lines (113 loc) · 2.79 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
const webpack = require("webpack");
const path = require("path");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const HtmlWebpackPugPlugin = require("html-webpack-pug-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer")
.BundleAnalyzerPlugin;
module.exports = (env, argv) => {
const isDevelopment = argv.mode === "development";
return {
entry: {
index: "./src/pages/articles/index.js"
},
output: {
filename: "[name].bundle.js",
path: path.join(__dirname, "dist")
},
module: {
rules: [
{
test: /\.pug$/,
loader: "pug-loader"
},
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: ["babel-loader", "eslint-loader"]
},
{
test: /\.(sa|sc|c)ss$/i,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
hmr: true,
reloadAll: true
}
},
{
loader: "css-loader",
options: {
importLoaders: 2,
sourceMap: true
}
},
{
loader: "resolve-url-loader"
},
{
loader: "sass-loader",
options: {
sourceMap: true
}
}
]
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/,
use: ["file-loader"]
},
{
test: /\.(png|jpg|gif)$/,
use: ["file-loader"]
},
{
test: /\.svg$/,
use: ["@svgr/webpack"]
}
]
},
devtool: isDevelopment ? "#eval-source-map" : false,
devServer: {
contentBase: path.join(__dirname, "dist"),
port: 3000,
stats: {
children: false,
maxModules: 0
},
historyApiFallback: true,
openPage: "/"
},
plugins: [
new HtmlWebpackPlugin({
filename: "index.html",
template: "./src/pages/articles/index.pug"
}),
require("autoprefixer"),
new MiniCssExtractPlugin({
filename: "[name].css",
chunkFilename: "[id].css",
ignoreOrder: false
}),
new BundleAnalyzerPlugin()
],
optimization: {
minimizer: [
new OptimizeCSSAssetsPlugin({
cssProcessorOptions: {
safe: true
}
})
],
splitChunks: {
chunks: "all"
}
},
performance: {
hints: process.env.NODE_ENV === "production" ? "warning" : false
}
};
};