gatsby-plugin-sass prevents configuration of CSS Loader
See original GitHub issueDescription
When setting the following options to gatsby-config.js
:
module.exports = {
plugins: [
{
resolve: `gatsby-plugin-sass`,
options: {
cssLoaderOptions: {
modules: {
exportLocalsConvention: 'camelCaseOnly'
}
}
}
}
]
}
We expect the exports of css-loader
to be camelCaseOnly
and not dashesOnly
(default).
Steps to reproduce
Very straightforward, just place this in a Gatsby SASS project.
Expected result
The webpack configuration should be modified accordingly and the exported values should be in camel case.
Actual result
Nothing changes. After investigation, it seems that the culprit is in gatsby-plugin-sass/gatsby-node.js
where there is the following:
const sassRuleModules = {
test: sassRuleModulesTest || /\.module\.s(a|c)ss$/,
use: [!isSSR && loaders.miniCssExtract({
modules: true
}), loaders.css({
importLoaders: 2,
...cssLoaderOptions,
modules: true
}), loaders.postcss({
plugins: postCssPlugins
})].filter(Boolean)
};
This causes the modules option to be overwritten even if it was provided. There should be a check to see if there is already a modules option to prevent overwriting.
Environment
System:
OS: Windows 10 10.0.19041
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Binaries:
Node: 15.3.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.10 - ~\AppData\Roaming\npm\yarn.CMD
npm: 6.14.9 - ~\AppData\Roaming\npm\npm.CMD
Languages:
Python: 3.6.4
Browsers:
Chrome: 88.0.4324.190
Edge: Spartan (44.19041.423.0), Chromium (88.0.705.81)
npmPackages:
gatsby: ^3.0.0 => 3.0.0
gatsby-plugin-mdx: ^2.0.0 => 2.0.0
gatsby-plugin-sass: ^4.0.0 => 4.0.0
gatsby-source-filesystem: ^3.0.0 => 3.0.0
gatsby-telemetry: ^2.0.0 => 2.0.0
npmGlobalPackages:
undefined: 0.1.0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top Results From Across the Web
gatsby-plugin-sass
gatsby -plugin-sass Provides drop-in support for Sass/SCSS stylesheets Install How ... If you need to override the default options passed into css-loader ....
Read more >CSS Modules + Sass Setup for Gatsby - Mediacurrent
CSS Modules provides a familiar approach to working with Sass -- even if you're not well-versed in Gatsby. Here's how to get started....
Read more >Gatsby, problem with using SCSS Modules, css works ...
I'm just guessing that it is something with project configuration, some problem with node, webpack, etc. but I've no idea what it is ......
Read more >GatsbyJS Tutorials #3 - Adding Plugins & Using Sass - YouTube
Subscribe for more free tutorials https://goo.gl/6ljoFcBecome A Native App Developer with React & React ...
Read more >Styling Gatsby Site with CSS - Ibaslogic
After that, import the CSS file in the Layout component like so: import ". ... Now, the sass plugin we will install is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the info and the note that the README will need an update. We’ll look into both things 😃
@juanbiberretta It’s been released in
gatsby-plugin-sass@4.0.1
😃We publish a minor every two weeks and hotfixes ad-hoc.