2

I have a basic Nuxt.js application. I wonder if it is possible to build the output into a single file (all the .js and .css files combined)?

It is possible to do it with just Vue.js following this answer https://stackoverflow.com/a/58309522/1666623 and I am looking for the same for Nuxt.js.

My reason to try to do that: the result might be embedded using a client's CMS, but it allows just single html files (it works ok with Vue.js output from the above link).

Michal Skop
  • 1,349
  • 1
  • 15
  • 23

1 Answers1

0

I'm not a webpack expert, so I'm not sure how this works. I have this answer and info here: https://stackoverflow.com/a/67526276/8816585

Basically saying that you can extend Webpack's configuration with something like this, or some other keys as explained in the docs. Not sure at all about the syntax tho.

export default {
  build: {
    extend(config, { isClient }) {
      // Extend only webpack config for client-bundle
      if (isClient) {
        config.devtool = 'source-map'
      }
    }
  }
}
kissu
  • 40,416
  • 14
  • 65
  • 133
  • There is a `splitChunks` for `build` in `nuxt.config.js`, which reduces the number of `.js` files in `dist/_nuxt/`, but there are still many such files, not a single `.html` with all the code together. It is in the answer to https://stackoverflow.com/a/67526276/8816585 – Michal Skop Aug 10 '21 at 20:18