Missing CSS and JS Files in Nuxt.js Build

I have made some configurations in Nuxt.js, successfully removing hash values from generated files. However, after running the build, I’ve noticed that there are no CSS and JS files in the ‘dist’ folder. Can someone help me troubleshoot this issue ?

My Code

  vite: {
    build: {
      rollupOptions: {
        output: {
          entryFileNames: `assets/[name].js`,
          chunkFileNames: `assets/[name].js`,

          assetFileNames: (assetInfo) => {
            if (assetInfo.name.endsWith('.css'))
              return 'assets/css/[name][extname]'

            if (/\.(png|jpe?g|gif|svg|webp)$/i.test(assetInfo.name))

              return 'assets/img/[name][extname]'

            if (/\.(woff|woff2|eot|ttf|otf)$/i.test(assetInfo.name))

              return 'assets/fonts/[name][extname]'

            if (/\.(mp4|webm|ogv)$/i.test(assetInfo.name))

              return 'assets/videos/[name][extname]'

            return 'assets/[name][extname]'
          },
        },
      },
    },
  },

My Github Demo Repo

https://github.com/Michael0520/nuxt3-test-deploy/tree/main

Final Dist ScreenShot

enter image description here

  • So what is in the dist folder?

    – 

  • 1

    @Phil, Hello, thank you for your response. I have included screenshots of the contents of the ‘dist’ folder in the question. The ‘dist’ folder contains the index.html for the Multi-Page Application (MPA) as well as image files, but it does not include CSS and JavaScript files.

    – 




  • Why do you wish to remove the hash here? There is maybe an option for that already btw? Even tho cache-invalidation will be rather annoying in that case, especially with a SW?

    – 

Leave a Comment