From 9fef497cc604afbeaec59989ffbddf6cd2d0e02f Mon Sep 17 00:00:00 2001 From: Alexander Talyuk Date: Fri, 10 Mar 2023 14:04:49 -0800 Subject: [PATCH 1/4] Set CSS modules mode depending on file type --- package/utils/get_style_rule.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/package/utils/get_style_rule.js b/package/utils/get_style_rule.js index 84724f0a..e4a93330 100644 --- a/package/utils/get_style_rule.js +++ b/package/utils/get_style_rule.js @@ -2,6 +2,8 @@ const { canProcess, moduleExists } = require('./helpers') const inliningCss = require('../inliningCss') +const isModuleFile = (filename) => !!filename.match(/\.module\.\w+(\.erb)?$/i) + const getStyleRule = (test, preprocessors = []) => { if (moduleExists('css-loader')) { const tryPostcss = () => @@ -18,7 +20,10 @@ const getStyleRule = (test, preprocessors = []) => { loader: require.resolve('css-loader'), options: { sourceMap: true, - importLoaders: 2 + importLoaders: 2, + modules: { + mode: resourcePath => isModuleFile(resourcePath) ? 'local' : 'icss' + } } }, tryPostcss(), From f6be520b2c0143f06b0e36d4a670375583a40830 Mon Sep 17 00:00:00 2001 From: Alexander Talyuk Date: Fri, 10 Mar 2023 14:23:13 -0800 Subject: [PATCH 2/4] Changelog added --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae5de188..03546997 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ Changes since last non-beta release. _Please add entries here for your pull requests that are not yet released._ +### Improved +- Set CSS modules mode depending on file type. [PR 261](https://github.com/shakacode/shakapacker/pull/261) by [talyuk](https://github.com/talyuk). ## [v6.6.0] - March 7, 2023 ### Improved @@ -22,7 +24,7 @@ _Please add entries here for your pull requests that are not yet released._ - Fixed [issue](https://github.com/shakacode/shakapacker/issues/208) to support directories under `node_modules/*` in the `additional_paths` property of `webpacker.yml` [PR 240](https://github.com/shakacode/shakapacker/pull/240) by [vaukalak](https://github.com/vaukalak). - Remove duplicate yarn installs. [PR 238](https://github.com/shakacode/shakapacker/pull/238) by [justin808](https://github/justin808). -- Remove unneeded code related to CSP config for generator. [PR 223](https://github.com/shakacode/shakapacker/pull/223) by [ahangarha](https://github/ahangarha). +- Remove unneeded code related to CSP config for generator. [PR 223](https://github.com/shakacode/shakapacker/pull/223) by [ahangarha](https://github/ahangarha). ## [v6.5.5] - December 28, 2022 From 6a0c15d5c61e19600b1f101d99af250a6aa43dd1 Mon Sep 17 00:00:00 2001 From: Tom Dracz Date: Tue, 4 Apr 2023 12:10:17 +0100 Subject: [PATCH 3/4] Update get_style_rule.js Use `mode: 'auto'` --- package/utils/get_style_rule.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/package/utils/get_style_rule.js b/package/utils/get_style_rule.js index e4a93330..77281eae 100644 --- a/package/utils/get_style_rule.js +++ b/package/utils/get_style_rule.js @@ -2,8 +2,6 @@ const { canProcess, moduleExists } = require('./helpers') const inliningCss = require('../inliningCss') -const isModuleFile = (filename) => !!filename.match(/\.module\.\w+(\.erb)?$/i) - const getStyleRule = (test, preprocessors = []) => { if (moduleExists('css-loader')) { const tryPostcss = () => @@ -22,7 +20,7 @@ const getStyleRule = (test, preprocessors = []) => { sourceMap: true, importLoaders: 2, modules: { - mode: resourcePath => isModuleFile(resourcePath) ? 'local' : 'icss' + mode: 'auto' } } }, From b0ff93fdd2fd80575ce8d7a90a1f0cd326a4eb5c Mon Sep 17 00:00:00 2001 From: Tom Dracz Date: Tue, 4 Apr 2023 12:10:58 +0100 Subject: [PATCH 4/4] Update get_style_rule.js --- package/utils/get_style_rule.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/utils/get_style_rule.js b/package/utils/get_style_rule.js index 77281eae..73390992 100644 --- a/package/utils/get_style_rule.js +++ b/package/utils/get_style_rule.js @@ -20,7 +20,7 @@ const getStyleRule = (test, preprocessors = []) => { sourceMap: true, importLoaders: 2, modules: { - mode: 'auto' + auto: true } } },