Skip to content

Commit 4d37843

Browse files
refactor: enable logic
1 parent be9838b commit 4d37843

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

lib/module.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,8 @@ function nuxtPurgeCss (moduleOptions) {
4040
config.paths = glob.sync(config.paths.map(p => path.join(srcDir, p)))
4141

4242
if (!enabled) {
43-
if (typeof purgeCSS.enabled === 'undefined') {
44-
logger.info('PurgeCSS is not enabled because you are in dev mode')
45-
return
46-
}
47-
logger.warn('Module is not enabled')
43+
const msg = this.options.dev ? 'PurgeCSS is not enabled because you are in dev mode' : 'Module is not enabled'
44+
logger.info(msg)
4845
return
4946
}
5047

@@ -58,7 +55,7 @@ function nuxtPurgeCss (moduleOptions) {
5855
logger.error('Webpack mode only works with build.extractCSS set to *true*. Either extract your CSS or use \'postcss\' mode')
5956
return
6057
}
61-
this.extendBuild(webpackFn(enabled, config))
58+
this.extendBuild(webpackFn(config))
6259
return
6360
}
6461

@@ -92,10 +89,7 @@ function nuxtPurgeCss (moduleOptions) {
9289
logger.success('Module initialized in postcss mode')
9390
}
9491

95-
const webpackFn = (enabled, purgeCssConfig) => (config, ctx) => {
96-
if (typeof enabled === 'function' && !enabled(ctx)) {
97-
return
98-
}
92+
const webpackFn = purgeCssConfig => (config) => {
9993
const PurgeCssPlugin = require('purgecss-webpack-plugin')
10094
config.plugins.push(new PurgeCssPlugin(purgeCssConfig))
10195
logger.success('Module initialized in webpack mode')

0 commit comments

Comments
 (0)