/
webpack.config.js
54 lines (51 loc) · 1.47 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
const path = require('path')
const glob = require('glob')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const PurgecssPlugin = require('../../../src/').default
const customExtractor = (content) => content.match(/[A-z0-9-:/]+/g) || [];
const PATHS = {
src: path.join(__dirname, 'src')
}
module.exports = {
mode: 'development',
entry: './src/index.js',
context: path.resolve(__dirname),
optimization: {
splitChunks: {
cacheGroups: {
styles: {
name: 'styles',
test: /\.css$/,
chunks: 'all',
enforce: true
}
}
}
},
module: {
rules: [
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader']
}
]
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css'
}),
new PurgecssPlugin({
paths: () => glob.sync(`${PATHS.src}/*`),
whitelist: () => ['whitelisted'],
whitelistPatterns: () => [/^whitelistedPat/],
whitelistPatternsChildren: () => [/^whitelistedPatternChildren/],
whitelistPatternsGreedy: () => [/^whitelistedPatternGreedy/],
extractors: [
{
extractor: customExtractor,
extensions: ['html', 'js']
}
]
})
]
}