|
1 | | -const path = require('path') |
2 | | -const glob = require('glob') |
3 | | -const MiniCssExtractPlugin = require('mini-css-extract-plugin') |
4 | | -const PurgecssPlugin = require('../../../src/').default |
| 1 | +const path = require("path"); |
| 2 | +const glob = require("glob"); |
| 3 | +const MiniCssExtractPlugin = require("mini-css-extract-plugin"); |
| 4 | +const PurgecssPlugin = require("../../../src/").default; |
5 | 5 |
|
6 | 6 | class CustomExtractor { |
7 | | - static extract(content) { |
8 | | - return content.match(/[A-z0-9-:/]+/g) |
9 | | - } |
| 7 | + static extract(content) { |
| 8 | + return content.match(/[A-z0-9-:/]+/g); |
| 9 | + } |
10 | 10 | } |
11 | 11 |
|
12 | 12 | const PATHS = { |
13 | | - src: path.join(__dirname, 'src') |
14 | | -} |
| 13 | + src: path.join(__dirname, "src") |
| 14 | +}; |
15 | 15 |
|
16 | 16 | module.exports = { |
17 | | - mode: 'development', |
18 | | - entry: './src/index.js', |
19 | | - optimization: { |
20 | | - splitChunks: { |
21 | | - cacheGroups: { |
22 | | - styles: { |
23 | | - name: 'styles', |
24 | | - test: /\.css$/, |
25 | | - chunks: 'all', |
26 | | - enforce: true |
27 | | - } |
28 | | - } |
| 17 | + mode: "development", |
| 18 | + entry: "./src/index.js", |
| 19 | + optimization: { |
| 20 | + splitChunks: { |
| 21 | + cacheGroups: { |
| 22 | + styles: { |
| 23 | + name: "styles", |
| 24 | + test: /\.css$/, |
| 25 | + chunks: "all", |
| 26 | + enforce: true |
29 | 27 | } |
30 | | - }, |
31 | | - module: { |
32 | | - rules: [ |
33 | | - { |
34 | | - test: /\.css$/, |
35 | | - use: [MiniCssExtractPlugin.loader, 'css-loader'] |
36 | | - } |
37 | | - ] |
38 | | - }, |
39 | | - plugins: [ |
40 | | - new MiniCssExtractPlugin({ |
41 | | - filename: '[name].css' |
42 | | - }), |
43 | | - new PurgecssPlugin({ |
44 | | - paths: () => glob.sync(`${PATHS.src}/*`), |
45 | | - whitelist: () => ['whitelisted'], |
46 | | - whitelistPatterns: () => [/^whitelistedPat/], |
47 | | - extractors: [ |
48 | | - { |
49 | | - extractor: CustomExtractor, |
50 | | - extensions: ['html', 'js'] |
51 | | - } |
52 | | - ] |
53 | | - }) |
| 28 | + } |
| 29 | + } |
| 30 | + }, |
| 31 | + module: { |
| 32 | + rules: [ |
| 33 | + { |
| 34 | + test: /\.css$/, |
| 35 | + use: [MiniCssExtractPlugin.loader, "css-loader"] |
| 36 | + } |
54 | 37 | ] |
55 | | -} |
| 38 | + }, |
| 39 | + plugins: [ |
| 40 | + new MiniCssExtractPlugin({ |
| 41 | + filename: "[name].css" |
| 42 | + }), |
| 43 | + new PurgecssPlugin({ |
| 44 | + paths: () => glob.sync(`${PATHS.src}/*`), |
| 45 | + whitelist: () => ["whitelisted"], |
| 46 | + whitelistPatterns: () => [/^whitelistedPat/], |
| 47 | + whitelistPatternsChildren: () => [/^whitelistedPatternChildren/], |
| 48 | + extractors: [ |
| 49 | + { |
| 50 | + extractor: CustomExtractor, |
| 51 | + extensions: ["html", "js"] |
| 52 | + } |
| 53 | + ] |
| 54 | + }) |
| 55 | + ] |
| 56 | +}; |
0 commit comments