Problem when importing global styles in nuxt.config
See original GitHub issueEnvironment
- Operating System:
Linux
- Node Version:
v14.17.1
- Nuxt Version:
3-3.0.0-27234211.2a0afbd
- Package Manager:
Yarn
- Bundler:
Webpack
- User Config:
meta
- Runtime Modules:
-
- Build Modules:
-
Describe the bug and expected behavior
I am trying to globally import a stylesheet into nuxt.config.js:
import { defineNuxtConfig } from 'nuxt3'
export default defineNuxtConfig({
meta: {
style: [
'~/assets/scss/global.scss',
]
}
})
But when launching the application, there are several errors in the console and terminal:
entry.mjs:39 Error while mounting app: DOMException: Failed to execute 'setAttribute' on 'Element': '0' is not a valid attribute name.
at createElement (http://localhost:3000/_nuxt/node_modules/@vueuse/head/dist/index.mjs?v=8287862b:47:10)
at insertTags (http://localhost:3000/_nuxt/node_modules/@vueuse/head/dist/index.mjs?v=8287862b:199:22)
at Object.updateDOM (http://localhost:3000/_nuxt/node_modules/@vueuse/head/dist/index.mjs?v=8287862b:259:7)
at http://localhost:3000/_nuxt/node_modules/nuxt3/dist/meta/runtime/lib/vueuse-head.plugin.mjs:14:12
at callWithErrorHandling (http://localhost:3000/_nuxt/node_modules/.vite/vue.js?v=8287862b:6280:18)
at callWithAsyncErrorHandling (http://localhost:3000/_nuxt/node_modules/.vite/vue.js?v=8287862b:6288:17)
at ReactiveEffect.getter [as fn] (http://localhost:3000/_nuxt/node_modules/.vite/vue.js?v=8287862b:6564:16)
at ReactiveEffect.run (http://localhost:3000/_nuxt/node_modules/.vite/vue.js?v=8287862b:391:21)
at doWatch (http://localhost:3000/_nuxt/node_modules/.vite/vue.js?v=8287862b:6645:13)
at watchEffect (http://localhost:3000/_nuxt/node_modules/.vite/vue.js?v=8287862b:6502:10)
An incorrect file link appears in the <head> tag:
<style 0="~" 1="/" 2="a" 3="s" 4="s" 5="e" 6="t" 7="s" 8="/" 9="s" 10="c" 11="s" 12="s" 13="/" 14="g" 15="l" 16="o" 17="b" 18="a" 19="l" 20="." 21="s" 22="c" 23="s" 24="s"></style>
Steps to reproduce
Steps to reproduce the behavior:
- Create file assets/scss/global.scss
- Go to nuxt.config.js
- Add follow code inside defineNuxtConfig function
meta: {
style: [
'~/assets/scss/global.scss',
]
}
- run yarn dev
- Open localhost:3000 and see an error in console and wrong <script> tag inside <head> tag
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
why nuxt.js global css on config is not working? - Stack Overflow
I try to put css files on assets assest/css/style.css and call it to my nuxt.config.js but it is not working i need to...
Read more >Configuration - Nuxt
The axios-module cannot be used in nuxt.config.js . You will need to import axios and configure it again. Further configuration.
Read more >Globally accessible CSS and SCSS/ SASS in your Nuxt ...
To import global css, open your nuxt.config.js file and navigate to the css array, here you can add any global CSS.
Read more >Troubles applying global scss : r/Nuxt - Reddit
Install this https://github.com/nuxt-community/style-resources-module ... but read the warning. Otherwise you would need to import your ...
Read more >Getting Started - BootstrapVue
Bootstrap v4 CSS employs a handful of important global styles and settings that you'll need to be aware of when using it, all...
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
You can apparently import your global styles in the css property, same as in nuxt 2:
Edit: It also works with scss, just have to
yarn add sass
.Actually it started working. Thanks