-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
74 lines (71 loc) · 1.93 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
68
69
70
71
72
73
74
const path = require("path");
const srcPath = path.join(__dirname, "app/src");
const glob = require("glob");
const webpack = require('webpack');
const autoprefixer = require("autoprefixer");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CssMinimizerWebpackPlugin = require("css-minimizer-webpack-plugin");
const { PurgeCSSPlugin } = require("purgecss-webpack-plugin");
module.exports = {
entry: {
index: "./app/src/js/index.js",
bootstrap: "./app/src/js/bootstrap.js",
},
output: {
filename: "asset/js/[name].bundle.js",
path: path.resolve(__dirname, "app/dist"),
clean: true,
},
devServer: {
static: path.resolve(__dirname, "app/dist"),
port: 8080,
hot: true,
open: true,
watchFiles: ["./app/src/**/*", "./app/src/*"],
},
optimization: {
minimize: true,
minimizer: [new CssMinimizerWebpackPlugin(), "..."],
splitChunks: {
cacheGroups: {
styles: {
name: "styles",
test: /\.css$/,
chunks: "all",
enforce: true,
},
},
},
},
plugins: [
new HtmlWebpackPlugin({ template: "./app/src/index.html", hash: true }),
new MiniCssExtractPlugin({ filename: "asset/css/bundle.css" }),
new CssMinimizerWebpackPlugin(),
new PurgeCSSPlugin({
paths: glob.sync(`${srcPath}/**/*`, { nodir: true }),
}),
new webpack.optimize.ModuleConcatenationPlugin()
],
module: {
rules: [
{
test: /\.(scss)$/,
use: [
MiniCssExtractPlugin.loader,
{ loader: "css-loader" },
{
// Loader for webpack to process CSS with PostCSS
loader: "postcss-loader",
options: {
postcssOptions: {
plugins: () => [autoprefixer],
},
},
},
{ loader: "sass-loader" },
],
},
],
},
};