Saturday, 1 May 2021

Href and src generated by Nuxt in static site are not properly linked to js files after nuxt generate

I'm running into a small problem with Nuxt whenever I generate a static site.

Whenever I do nuxt generate most of the js files arent linked properly.

In the index.html I generate, js files link to href="/_nuxt/9f10f95.js" for example. Whenever I remove the leading / (or make it like this ./, the link works correctly.

enter image description here

Because it's a bit redundant to remove every / after everytime I generate, is there a way for Nuxt to link these files correctly on nuxt generate?

I have already set ssr: true, which also fixed some problems. But the problem I described above persists.

EDIT: My nuxt.config.js

export default {
  ssr: true,
  target: 'static',

  head: {
    title: 'my-website',
    htmlAttrs: {
      lang: 'en'
    },
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: '' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: 'favicon.ico' },
      { rel: 'preconnect', href: 'https://fonts.gstatic.com' },
      { href: 'https://fonts.googleapis.com/css2?family=Open+Sans+Condensed:wght@300;700&family=Open+Sans:wght@400;700&display=swap', rel: 'stylesheet' }
    ]
  },

  css: [
  ],

  plugins: [
  ],

  components: true,

  buildModules: [
    // https://go.nuxtjs.dev/tailwindcss
    '@nuxtjs/tailwindcss',
  ],

  modules: [
  ],

  build: {
  }
}


from Href and src generated by Nuxt in static site are not properly linked to js files after nuxt generate

No comments:

Post a Comment