diff --git a/purgecss.config.js b/purgecss.config.js new file mode 100644 index 00000000..427c029b --- /dev/null +++ b/purgecss.config.js @@ -0,0 +1,9 @@ +let glob = require('glob-all') + +module.exports = { + defaultExtractor: content => content.match(/[\w-/:]+(? glob.sync([ + 'assets/**/*.vue', + 'source/**/*.{md,twig}' + ]) +} diff --git a/webpack.config.js b/webpack.config.js index a8bea6a8..cac42348 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -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-/:]+(? glob.sync([ - 'assets/**/*.vue', - 'source/**/*.{md,twig}' - ]) - })) + Encore.addPlugin(new PurgecssPlugin(PurgecssConfig)) } module.exports = Encore.getWebpackConfig()