I have numerous Vue SPAs in a monorepo that all share a common set of global styles, each SPA and the styles are their own
package.json
The global styles are
.scss
As such, I did a fresh install of Nuxt and then ran:
yarn add -D sass [email protected] fibers
I know I can get global styles like so:
//in nuxt.config.js: css: [resolve(__dirname+'/../common/styles/index.scss')
Really I thought that should/would be it, and I see it does get injected into the page. However, the class names are hashed, so it doesn’t apply to my components.
Instead of this (fake css to test if it goes in the page):
.test{ text-align: test; top: test; }
I get this:
.olAmdkaWN_JnK1npjbKiI { text-align: test; top: test; }
How can I stop the global styles from being hashed like this, especially when I may be importing components from the other SPAs/
common
I’ve tried various attempts at setting the
localIdentName
//in nuxt.config.js build: { extend(config) { config.module.rules.push({ test: /.scss$/, use: [{ loader: 'css-loader', options: { modules: false /* or sometimes I'll try something like: modules:{ localIdentName: '[local]' } */ } }, { loader: 'sass-loader' } ] }) },
I’ve also set:
cssModules: { localIdentName: '[local]' },
Again in the
nuxt.config.js
My nuxt, webpack and sass-loader verisons are as follows:
[email protected] [email protected] [email protected] (It was at 7.1.x but the console suggested upgrading it - didn't make a difference in terms of solving this)
package.json
"dependencies": { "core-js": "^3.9.1", "common": "1.0.0", (local dependency) "nuxt": "^2.15.3" }, "devDependencies": { "fibers": "^5.0.0", "sass": "^1.32.11", "sass-loader": "10" }
Recent Comments