Split PurgeCSS configuration

This commit is contained in:
Oliver Davies 2019-12-09 12:00:00 +00:00
parent 0095f72d61
commit 595b9f74e6
2 changed files with 13 additions and 10 deletions

9
purgecss.config.js Normal file
View file

@ -0,0 +1,9 @@
let glob = require('glob-all')
module.exports = {
defaultExtractor: content => content.match(/[\w-/:]+(?<!:)/g) || [],
paths: () => glob.sync([
'assets/**/*.vue',
'source/**/*.{md,twig}'
])
}

View file

@ -1,6 +1,6 @@
const Encore = require('@symfony/webpack-encore')
const glob = require('glob-all')
const PurgecssPlugin = require('purgecss-webpack-plugin')
let Encore = require('@symfony/webpack-encore')
let PurgecssConfig = require('./purgecss.config')
let PurgecssPlugin = require('purgecss-webpack-plugin')
Encore
.disableSingleRuntimeChunk()
@ -13,13 +13,7 @@ Encore
.enableSourceMaps(!Encore.isProduction())
if (Encore.isProduction()) {
Encore.addPlugin(new PurgecssPlugin({
defaultExtractor: content => content.match(/[\w-/:]+(?<!:)/g) || [],
paths: () => glob.sync([
'assets/**/*.vue',
'source/**/*.{md,twig}'
])
}))
Encore.addPlugin(new PurgecssPlugin(PurgecssConfig))
}
module.exports = Encore.getWebpackConfig()