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 option to configure the CSS loader #335

Merged
merged 1 commit into from
Jul 14, 2018

Conversation

XWB
Copy link
Contributor

@XWB XWB commented Jun 11, 2018

Disabling the URL handler can be handy for importing legacy CSS.

Fixes #334

index.js Outdated
disableUrlHandling() {
webpackConfig.disableUrlHandling();

return this;
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I think a better idea would be to allow the css-loader to be configured in general. So, to create a method more like configureBabel(), where you pass it a callback, and we pass the callback the final config (which you can then modify). That'll allow you to disable the url handling... but also to modify any options on the css-loader.

@XWB
Copy link
Contributor Author

XWB commented Jun 19, 2018

@weaverryan I've made some changes, can you check it out?

Copy link
Collaborator

@Lyrkan Lyrkan left a comment

Choose a reason for hiding this comment

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

Hi @XWB,

I agree that'd be a useful addition to Encore (for instance it could help with #337 since it is not currently possible to easily disable/configure CSS minimization in production mode)

Could you also add some tests in test/loaders/css.js to check that the callback is correctly applied?

@@ -581,6 +581,22 @@ class Encore {
return this;
}

/**
* Configure the css-loader.
*
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you maybe add a link to https://github.com/webpack-contrib/css-loader#options there?

index.js Outdated
* Configure the css-loader.
*
* Encore.configureCssLoader(function(config) {
* // change the config
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd also add a small example there so users know what to do with the config object, for instance:

Encore.configureCssLoader(function(config) {
  config.minimize = true;
});

@stof stof changed the title Add option to disable the URL handler Add option to configure the CSS loader Jun 21, 2018
@XWB
Copy link
Contributor Author

XWB commented Jul 13, 2018

@Lyrkan @weaverryan All done.

@weaverryan
Copy link
Member

Thanks @XWB!

@weaverryan weaverryan merged commit 64935f1 into symfony:master Jul 14, 2018
weaverryan added a commit that referenced this pull request Jul 14, 2018
This PR was merged into the master branch.

Discussion
----------

Add option to configure the CSS loader

Disabling the URL handler can be handy for importing legacy CSS.

Fixes #334

Commits
-------

64935f1 Add css-loader configuration callback
@XWB XWB deleted the disable-url-handling branch July 15, 2018 16:14
@XWB
Copy link
Contributor Author

XWB commented Oct 31, 2018

@weaverryan Any idea when you will tag a new release that contains this feature?

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

3 participants