Skip to content

Add a boolean parameter to Encore.disableCssExtraction() #756

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/WebpackConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -810,8 +810,8 @@ class WebpackConfig {
this.useFontsLoader = false;
}

disableCssExtraction() {
this.extractCss = false;
disableCssExtraction(disabled = true) {
this.extractCss = !disabled;
}

configureFilenames(configuredFilenames = {}) {
Expand Down
17 changes: 16 additions & 1 deletion test/WebpackConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down