forked from Purdue/purdue-wp-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
56 lines (54 loc) · 1.63 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
const path = require('path');
// include the js minification plugin
const TerserPlugin = require("terser-webpack-plugin");
// include the css extraction and minification plugins
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
// include the clean webpack plugins
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
module.exports = {
entry: {
app:['./src/js/front-end/app.js', './src/style/front-end/app.scss'],
admin:['./src/js/back-end/admin.js', './src/style/back-end/admin.scss'],
customizer:['./src/js/back-end/customizer.js'],
},
output: {
filename: './build/js/[name].[hash].js',
path: path.resolve(__dirname)
},
module: {
rules: [
// perform js babelization on all .js files
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
}
},
// compile all .scss files to plain old css
{
test: /\.(sass|scss)$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader', 'sass-loader']
}
]
},
plugins: [
// extract css into dedicated file
new MiniCssExtractPlugin({
filename: './build/css/[name].[hash].css'
}),
// clean out build directories on each build
new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: ['./build/js/*','./build/css/*']
})
],
optimization: {
minimizer: [
// enable the js minification plugin
new TerserPlugin(),
// enable the css minification plugin
new CssMinimizerPlugin({})
]
}
};