Skip to content
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

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

Merged

Conversation

football2801
Copy link
Contributor

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

@Lyrkan Lyrkan changed the title Allow envvars disablecssextraction Add a boolean parameter to Encore.disableCssExtraction() May 9, 2020
@Lyrkan
Copy link
Collaborator

Lyrkan commented May 9, 2020

Hi @football2801,

Thank you for this PR, I renamed it since it isn't actually related to environment variables.

We thought a while ago about adding something like this but didn't because it could be a bit confusing for the users (see the responses to #564 (comment)).

If you look at the other methods with that kind of parameter you'll see that they are all named enable<something>(). For them having an "enable" parameter is not ambiguous at all: setting it to true will enable the related feature.

Now for a disable<something>() method it is a bit different, especially if it is between other enable<something>() methods in your webpack.config.js...

@football2801
Copy link
Contributor Author

football2801 commented May 11, 2020

After reading everything in that comment that you tagged, @Lyrkan, I agree with the comments you were making. I don't find it the least bit confusing. I actually made this PR due to people that I work with that requested that this method have this optional param. I know it would make my config file that much prettier.

@Lyrkan
Copy link
Collaborator

Lyrkan commented May 11, 2020

Ping @Kocal & @weaverryan

@JShilling4
Copy link

I am in favor of this PR. I agree with @Lyrkan comment in #564. This PR makes total sense to me and keeps the config clean and consistent.

(do you want to disable CSS extraction?)
.disableCssExtraction(true) => yes, disable
.disableCssExtraction(false) => no, don't disable

Even placed with enables, this does not confuse me at all:

(do you want to enable source maps?)
.enableSourceMaps(true) => yes, enable
.enableSourceMaps(false) => no, don't enable

index.js Outdated
* @returns {Encore}
*/
disableCssExtraction() {
webpackConfig.disableCssExtraction();
disableCssExtraction(enabled = true) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it mean you enable the CSS extraction disabling? :D

@Kocal
Copy link
Contributor

Kocal commented May 11, 2020

I'm not a big fan of .disable*() methods, especially when it take an argument which is named enabled and can lead to confusion (do we enable or disable the functionnality?).

IMO, the best option is to:

  • rename disableCssExtraction() to enableCssExtraction
  • it takes a new argument enabled, like other .enable*() methods
  • it should be documented as a breaking change, and update symfony-docs if needed

@football2801
Copy link
Contributor Author

football2801 commented May 11, 2020

@Kocal, enabling CSS extraction is the default behavior. The CSS extraction takes place without any webpack.config.js entries. This would not only be a breaking change for those who use the .disableCssExtraction() method, but wouldn't it also be a breaking change for everybody else too since their webpack.config.js file would not contain the new .enableCssExtraction()?

@Kocal
Copy link
Contributor

Kocal commented May 12, 2020

Okay it makes sense, but I think we need to update the parameter enabled to disabled, see #756 (comment).

Encore.disableCssExtraction(disabled = true) to disable the feature, Encore.disableCssExtraction(disabled = false) to not disable the feature.

What do you think?

@Lyrkan
Copy link
Collaborator

Lyrkan commented May 12, 2020

Having an enableCssExtraction() that is mandatory for almost all projects wouldn't be a good thing in my opinion.

Encore.disableCssExtraction(disabled = true) to disable the feature,
Encore.disableCssExtraction(disabled = false) to not disable the feature.

What do you think?

I agree with that.

@football2801
Copy link
Contributor Author

Encore.disableCssExtraction(disabled = true) to disable the feature, Encore.disableCssExtraction(disabled = false) to not disable the feature.

What do you think?

I can make this change. I see this as a valid change that may improve code readability and is not a breaking change.

Copy link
Contributor

@Kocal Kocal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Rodrigo001-dev

This comment has been minimized.

@weaverryan weaverryan changed the base branch from master to main November 18, 2020 18:25
@weaverryan weaverryan force-pushed the allow-envvars-disablecssextraction branch from 0c89aa2 to 3935566 Compare December 3, 2020 15:20
@weaverryan
Copy link
Member

Thanks @football2801! After initially not being sure about this, I've since wanted it in a few projects :)

@weaverryan
Copy link
Member

I proposed a few extra docs in #867 :)

weaverryan added a commit that referenced this pull request Dec 3, 2020
…e dev-server (weaverryan)

This PR was merged into the main branch.

Discussion
----------

adding docs related to disabling the css extraction and the dev-server

Extra docs for #756

Commits
-------

bff8f04 adding docs related to disabling the css extraction and the dev-server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants