From 595b9f74e68549314b94fe3080b8f70cc8396ee4 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Mon, 9 Dec 2019 12:00:00 +0000 Subject: [PATCH] Split PurgeCSS configuration --- purgecss.config.js | 9 +++++++++ webpack.config.js | 14 ++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 purgecss.config.js 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()