Skip to content

Commit f7a6c6b

Browse files
committed
feature #756 Add a boolean parameter to Encore.disableCssExtraction() (football2801)
This PR was squashed before being merged into the main branch. Discussion ---------- Add a boolean parameter to Encore.disableCssExtraction() Branch? | master -- | -- Bug fix? | no New feature? | yes Deprecations? | no Tickets | none License | MIT Allows for environment specific uses of disableCssExtraction that match conventions used in webpack.config.js by other methods such as enableSourceMaps or enableVersioning Commits ------- 3935566 Add a boolean parameter to Encore.disableCssExtraction()
2 parents 9f24246 + 3935566 commit f7a6c6b

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
@@ -1327,11 +1327,11 @@ class Encore {
13271327
*
13281328
* Internally, this disables the mini-css-extract-plugin
13291329
* and uses the style-loader instead.
1330-
*
1330+
* @param {boolean} disabled
13311331
* @returns {Encore}
13321332
*/
1333-
disableCssExtraction() {
1334-
webpackConfig.disableCssExtraction();
1333+
disableCssExtraction(disabled = true) {
1334+
webpackConfig.disableCssExtraction(disabled);
13351335

13361336
return this;
13371337
}

lib/WebpackConfig.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -846,8 +846,8 @@ class WebpackConfig {
846846
this.useFontsLoader = false;
847847
}
848848

849-
disableCssExtraction() {
850-
this.extractCss = false;
849+
disableCssExtraction(disabled = true) {
850+
this.extractCss = !disabled;
851851
}
852852

853853
configureFilenames(configuredFilenames = {}) {

test/WebpackConfig.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -1237,12 +1237,27 @@ describe('WebpackConfig object', () => {
12371237
expect(config.extractCss).to.be.true;
12381238
});
12391239

1240-
it('Calling it disables the CSS extraction', () => {
1240+
it('Calling it with no params disables the CSS extraction', () => {
12411241
const config = createConfig();
12421242
config.disableCssExtraction();
12431243

12441244
expect(config.extractCss).to.be.false;
12451245
});
1246+
1247+
it('Calling it with boolean set to true disables CSS extraction', () => {
1248+
const config = createConfig();
1249+
config.disableCssExtraction(true);
1250+
1251+
expect(config.extractCss).to.be.false;
1252+
});
1253+
1254+
it('Calling it with boolean set to false enables CSS extraction', () => {
1255+
const config = createConfig();
1256+
config.disableCssExtraction(false);
1257+
1258+
expect(config.extractCss).to.be.true;
1259+
});
1260+
12461261
});
12471262

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

0 commit comments

Comments
 (0)