-
Notifications
You must be signed in to change notification settings - Fork 3
/
config-overrides.js
45 lines (41 loc) · 1.08 KB
/
config-overrides.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
const path = require('path')
const PurgecssPlugin = require('purgecss-webpack-plugin')
const glob = require('glob-all')
const paths = {
appSrc: path.join(__dirname, 'src'),
appPublic: path.join(__dirname, 'public')
}
/*
Without this plugin Tailwind's default css creates a large artifact
File sizes after gzip:
58.38 KB build/static/css/main.15b71095.chunk.css
With this plugin it is much smaller
File sizes after gzip:
1.4 KB build/static/css/main.15b71095.chunk.css
*/
class TailwindExtractor {
static extract(content) {
return content.match(/[A-Za-z0-9-_:/]+/g) || []
}
}
module.exports = {
webpack: function(config, env) {
if (env === 'production') {
config.plugins.push(
new PurgecssPlugin({
paths: [
...glob.sync(`${paths.appPublic}/**/*`, { nodir: true }),
...glob.sync(`${paths.appSrc}/**/*`, { nodir: true })
],
extractors: [
{
extractor: TailwindExtractor,
extensions: ['tsx', 'html']
}
]
})
)
}
return config
}
}