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

Set CSS modules mode depending on file type #261

Merged
merged 4 commits into from
Apr 5, 2023

Conversation

talyuk
Copy link
Contributor

@talyuk talyuk commented Mar 10, 2023

Summary

Set CSS modules mode to icss if a style file is not a module, local otherwise. It allows using ICSS features such as :import and :export without using further CSS Module functionality. ICSS features were applied by default to all files before css-loader@v4, but it's been changed in the next versions. (Please refer to css-loader example)

@justin808
Copy link
Member

@talyuk Nice job! Would this change require an update to the imported version of css-loader?

I suspect that a few more comments in the change log requiring any migration would be helpful.

Or maybe some file in the https://github.com/shakacode/shakapacker/tree/master/docs directory? or README?

https://webpack.js.org/loaders/css-loader/#modules
image

importLoaders: 2
importLoaders: 2,
modules: {
mode: resourcePath => isModuleFile(resourcePath) ? 'local' : 'icss'
Copy link
Member

Choose a reason for hiding this comment

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

Why or why not could we use the auto: true

https://github.com/webpack-contrib/css-loader#auto

        options: {
          modules: {
            auto: true,
          },
        },

Copy link
Member

Choose a reason for hiding this comment

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

@talyuk any comment?

Copy link
Member

Choose a reason for hiding this comment

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

I skimmed through the docs, and it seems that auto: true is the best choice for this case since users should be familiar with the behavior and it already does what's proposed in this PR (correct me if I'm wrong). @talyuk What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1 auto: true is the sensible choice here

importLoaders: 2
importLoaders: 2,
modules: {
mode: resourcePath => isModuleFile(resourcePath) ? 'local' : 'icss'
Copy link
Collaborator

Choose a reason for hiding this comment

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

+1 auto: true is the sensible choice here

@justin808
Copy link
Member

@tomdracz or @talyuk, can you submit a PR with auto: true?

@tomdracz
Copy link
Collaborator

tomdracz commented Apr 4, 2023

Updated to use auto: true in this PR

@tomdracz tomdracz merged commit ae5aeb6 into shakacode:master Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants