Nuxt.js build into a single output file

Viewed 769

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).

1 Answers

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'
      }
    }
  }
}
Related