[Vuejs]-Loading a css file from 'assets' directory in a NUXT layout

6πŸ‘

βœ…

The image src is automatically compiled by Vue, you can see more at relative path import; From the docs:

all asset URLs such as <img src="...">, background: url(...) and CSS
@import are resolved as module dependencies.

For a custom path besides cases listed above, you need to explicitly require the path for it to be compiled as a path to static assets:

export default{
  head:{
    link: [{ rel: 'stylesheet', href: require('~assets/style.css') }]
  }
}
πŸ‘€Psidom

Leave a comment