Skip to content

how to compile to .js file not a .mjs file #17037

Answered by danielroe
Binaryify asked this question in Questions
Discussion options

You must be logged in to vote

I've opened nuxt/framework#6505 to allow this to be done more easily (see PR description).

But for now you can implement like this:

nuxt.hook('vite:extendConfig', (config, { isClient }) {
  if (isClient) {
    // rc6
    config.build.rollupOptions.output.chunkFileNames = '[hash].mjs'
    // rc7
    config.build.rollupOptions.output.chunkFileNames = '_nuxt/[hash].mjs'
  }
})

Replies: 0 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@sunnywanggit
Comment options

@danielroe
Comment options

Answer selected by Binaryify
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5 participants