From 3935566c2d89f9291ece07d25269d0aac1696c8d Mon Sep 17 00:00:00 2001 From: Matt Edholm Date: Thu, 7 May 2020 12:19:05 -0400 Subject: [PATCH] Add a boolean parameter to Encore.disableCssExtraction() --- index.js | 6 +++--- lib/WebpackConfig.js | 4 ++-- test/WebpackConfig.js | 17 ++++++++++++++++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 935e1764..627701cd 100644 --- a/index.js +++ b/index.js @@ -1299,11 +1299,11 @@ class Encore { * * Internally, this disables the mini-css-extract-plugin * and uses the style-loader instead. - * + * @param {boolean} disabled * @returns {Encore} */ - disableCssExtraction() { - webpackConfig.disableCssExtraction(); + disableCssExtraction(disabled = true) { + webpackConfig.disableCssExtraction(disabled); return this; } diff --git a/lib/WebpackConfig.js b/lib/WebpackConfig.js index 77f86aaf..b32c93c8 100644 --- a/lib/WebpackConfig.js +++ b/lib/WebpackConfig.js @@ -810,8 +810,8 @@ class WebpackConfig { this.useFontsLoader = false; } - disableCssExtraction() { - this.extractCss = false; + disableCssExtraction(disabled = true) { + this.extractCss = !disabled; } configureFilenames(configuredFilenames = {}) { diff --git a/test/WebpackConfig.js b/test/WebpackConfig.js index 55e3f919..5d99fe4e 100644 --- a/test/WebpackConfig.js +++ b/test/WebpackConfig.js @@ -1223,12 +1223,27 @@ describe('WebpackConfig object', () => { expect(config.extractCss).to.be.true; }); - it('Calling it disables the CSS extraction', () => { + it('Calling it with no params disables the CSS extraction', () => { const config = createConfig(); config.disableCssExtraction(); expect(config.extractCss).to.be.false; }); + + it('Calling it with boolean set to true disables CSS extraction', () => { + const config = createConfig(); + config.disableCssExtraction(true); + + expect(config.extractCss).to.be.false; + }); + + it('Calling it with boolean set to false enables CSS extraction', () => { + const config = createConfig(); + config.disableCssExtraction(false); + + expect(config.extractCss).to.be.true; + }); + }); describe('configureFilenames', () => {