3

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 Answer 1

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'
      }
    }
  }
}
Sign up to request clarification or add additional context in comments.

1 Comment

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 stackoverflow.com/a/67526276/8816585

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.