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

Added the possibility to configure the StyleLoader via the method Enc… #715

Merged
merged 10 commits into from
Apr 17, 2020
Merged

Added the possibility to configure the StyleLoader via the method Enc… #715

merged 10 commits into from
Apr 17, 2020

Conversation

tooltonix
Copy link

…ore.configureStyleLoader()

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 @tooltonix,

Thank you for this PR.

Besides the few remarks below the implementation looks good, but we'll also need some test cases to make sure that it works and will still work in the future :)

Also I'm wondering if this should be added as a separate method or directly as a disableCssExtraction() argument (since it is the only method that enables the loader)... what do you think? (not asking you to change it, I only want your opinion! Also, ping @weaverryan and @Kocal for the same question).

index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
lib/loaders/css-extract.js Outdated Show resolved Hide resolved
@Kocal
Copy link
Contributor

Kocal commented Mar 24, 2020

Hi 👋

Also I'm wondering if this should be added as a separate method or directly as a disableCssExtraction() argument (since it is the only method that enables the loader)

Hum, I am bit divided on this point but I think a separate method is better.

If we had use a disableCssExtraction() argument:

  • yes style-loader is only used if CSS extraction is disabled, but it feels weird to me to configure a loader in a method which is not named configure...Loader()
  • what if one day we use style-loader somewhere else? (but I can't imagine cases where it would be possible 😛)

But if we have a configureStyleLoader:

  • that's nice, a method for configuring a loader
  • but the loader is not active by default, only when the CSS extraction is disabled. We should warn the user about this

@tooltonix
Copy link
Author

Due to internal requirements, we use a different style loader, which we install per yarn, so that the options of the previous style loader are no longer applicable. In the latest version 1.1.3 of the StyleLoader, the loader automatically inject source maps when previous loader emit them.

It is correct that the method disableCssExtraction() activates the StyleLoader, but I would override the options with a separate method configureStyleLoader(), as it is more consistent for me in context and name.

lib/loaders/css-extract.js Outdated Show resolved Hide resolved
Copy link
Member

@weaverryan weaverryan left a comment

Choose a reason for hiding this comment

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

Hey @tooltonix!

This looks good to me - and I agree with the 2 separate methods, but I'm happy we had the conversation - I think it will help us with some docs to show that these methods are connected.

Only minor comments. But we do need a functional test for this. See functional.js - there is already a case that includes disableCssExtraction(). We could duplicate that test case, maybe set the attributes option to TESTING_ATTRIBUTES and then assert that this string is present inside main.js.

Cheers!

lib/loaders/css-extract.js Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
@tooltonix
Copy link
Author

Hey @tooltonix!

This looks good to me - and I agree with the 2 separate methods, but I'm happy we had the conversation - I think it will help us with some docs to show that these methods are connected.

Only minor comments. But we do need a functional test for this. See functional.js - there is already a case that includes disableCssExtraction(). We could duplicate that test case, maybe set the attributes option to TESTING_ATTRIBUTES and then assert that this string is present inside main.js.

Cheers!

Hi @weaverryan

I'm sorry, but I haven't written any tests in Mocha yet. But I tried anyway and the test was successful, as long as I used the correct options of the style loader in version 1.1.3. I hope that the test is sufficient. Otherwise I ask for appropriate suggestions.

@tooltonix tooltonix requested a review from Lyrkan April 3, 2020 10:56
@weaverryan
Copy link
Member

Very excellent work! Thanks so much for this Patrick!

@weaverryan weaverryan merged commit 0168b0b into symfony:master Apr 17, 2020
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

4 participants