I'm attempting to call files from the root static/css
folder into the head (via the nuxt.config.ts
file), but I can't work out how to get them to load.
Using npm run dev
, in case that matters?
My code:
export default defineNuxtConfig({
// loads / embeds css from file within a <style> element.
// this method works, but isn't the behavior I'm after
css: ['@/static/css/css-dev.css'],
app: {
head: {
link: [
// none of these work. No errors in terminal / console...
// the styles within the files just aren't recognized / used
{ rel: 'stylesheet', href: '@/css/css-dev.css' },
{ rel: 'stylesheet', href: '~/css/css-dev.css' },
{ rel: 'stylesheet', href: '/css/css-dev.css' },
{ rel: 'stylesheet', href: 'css/css-dev.css' },
]
}
}
})
The files are added to the page in the head, but are not actually linking to anything valid. Attempting to load the files in the browser (localhost:3000/css/css-dev.css) just opens the same index page - not the file I'm attempting to link to.
I have the same issues when using useHead
within another page (such as app.vue, or index.vue, etc).
export default {
setup() {
useHead({
link: [
{ rel: 'stylesheet', href: '/css/css-dev.css' }, // or any of the above path examples
]
})
},
}
This doesn't seem to be tied to only css files... loading a <meta property="og:image">
this way also has the same issues.
Can someone explain what I'm doing wrong?