I'm trying to load a mapboxgl stylesheet in a Nuxt 3.0.0-rc.8 application. Normally, for Vue projects, I manually add it to the head of the index.html page.
However, this is obviously not the approach in Nuxt 3. I tried adding it to the head and css options in the nuxt.config.ts file with no success. I did notice that when I added it to the css array, it was added to my header, but the "https://" was replaced with "_nuxt".
I know I'm missing something simple. This is my config file:
export default defineNuxtConfig({ css: [ '~/assets/css/main.css', ], build: { postcss: { postcssOptions: require('./postcss.config.js'), }, }, buildModules: ['@pinia/nuxt'], runtimeConfig: { treesAPIKey: '', public: { baseURL: '', mapToken: '', }, }, head: { link: [{ rel: 'stylesheet', href: 'https://api.mapbox.com/mapbox-gl-js/v2.6.1/mapbox-gl.css' }] }, });
Use
app.head
instead ofhead
.