-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
77 lines (75 loc) · 1.92 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
75
76
77
const glob = require('glob-all');
const path = require('path');
const CompressionPlugin = require('compression-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const PurgeCSSPlugin = require('purgecss-webpack-plugin');
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin');
module.exports = {
entry: {
bundle: ['./src/app/index.js', './scss/index.scss'],
polyfills: ['./src/app/utils/polyfill'],
sw: ['./src/serviceworker/index.js'],
},
output: {
path: path.join(__dirname, 'public'),
filename: '[name].js',
publicPath: '/',
},
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
},
},
{
test: /\.s?css$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
{
loader: 'sass-loader',
options: {
implementation: require('sass'),
},
},
],
},
],
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css',
}),
new PurgeCSSPlugin({
paths: glob.sync([
path.join(__dirname, 'src/app/**/*.js'),
path.join(__dirname, 'scss/**/*.scss'),
path.join(__dirname, 'src/**/*.ejs'),
]),
}),
new HtmlWebpackPlugin({
title: 'Chemist.li',
template: 'src/index.ejs',
minify: {
collapseWhitespace: true,
},
inlineSource: /\.css$/,
excludeChunks: ['polyfills', 'sw'],
}),
new ScriptExtHtmlWebpackPlugin({
defaultAttribute: 'async',
}),
new CompressionPlugin({
filename: '[path][base].gz[query]',
algorithm: 'gzip',
}),
new CompressionPlugin({
filename: '[path][base].br[query]',
algorithm: 'brotliCompress',
}),
],
};