Skip to content

Commit 3935566

Browse files
football2801weaverryan
authored andcommitted
Add a boolean parameter to Encore.disableCssExtraction()
1 parent 9700574 commit 3935566

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1299,11 +1299,11 @@ class Encore {
12991299
*
13001300
* Internally, this disables the mini-css-extract-plugin
13011301
* and uses the style-loader instead.
1302-
*
1302+
* @param {boolean} disabled
13031303
* @returns {Encore}
13041304
*/
1305-
disableCssExtraction() {
1306-
webpackConfig.disableCssExtraction();
1305+
disableCssExtraction(disabled = true) {
1306+
webpackConfig.disableCssExtraction(disabled);
13071307

13081308
return this;
13091309
}

lib/WebpackConfig.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -810,8 +810,8 @@ class WebpackConfig {
810810
this.useFontsLoader = false;
811811
}
812812

813-
disableCssExtraction() {
814-
this.extractCss = false;
813+
disableCssExtraction(disabled = true) {
814+
this.extractCss = !disabled;
815815
}
816816

817817
configureFilenames(configuredFilenames = {}) {

test/WebpackConfig.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -1223,12 +1223,27 @@ describe('WebpackConfig object', () => {
12231223
expect(config.extractCss).to.be.true;
12241224
});
12251225

1226-
it('Calling it disables the CSS extraction', () => {
1226+
it('Calling it with no params disables the CSS extraction', () => {
12271227
const config = createConfig();
12281228
config.disableCssExtraction();
12291229

12301230
expect(config.extractCss).to.be.false;
12311231
});
1232+
1233+
it('Calling it with boolean set to true disables CSS extraction', () => {
1234+
const config = createConfig();
1235+
config.disableCssExtraction(true);
1236+
1237+
expect(config.extractCss).to.be.false;
1238+
});
1239+
1240+
it('Calling it with boolean set to false enables CSS extraction', () => {
1241+
const config = createConfig();
1242+
config.disableCssExtraction(false);
1243+
1244+
expect(config.extractCss).to.be.true;
1245+
});
1246+
12321247
});
12331248

12341249
describe('configureFilenames', () => {

0 commit comments

Comments
 (0)