nuxt
nuxt copied to clipboard
nuxt generate execute nuxt.config.js twice when set target=static
Versions
- nuxt: v2.15.7
- node: v12.14.0
Reproduction
Steps to reproduce
- set
target: 'static'
innuxt.config.js
- add log in
nuxt.config.js
just under the module:console.log('hello')
- build with
nuxt generate
- the shell would show two
hello
What is Expected?
nuxt.config.js
only executes once.
What is actually happening?
https://github.com/nuxt/nuxt.js/blob/853439ddf945b6ee358d5912e6e5a68009633c27/packages/cli/src/commands/generate.js#L71-L75
https://github.com/nuxt/nuxt.js/blob/ab1c6cb442c9418128c85ad2cb14ed162af44933/packages/cli/src/utils/generate.js#L130-L131
ensureBuild()
and generate()
both call getNuxt()
which calls the cmd.getNuxtConfig()
. getNuxtConfig
method calls loadNuxtConfig()
later, which would clear the require cache before loading nuxt.config.js
. As a result, nuxt.config.js
would run twice.
Also happening to me, as I am trying to bump up from Nuxt 2.14.X to 2.15:
- Nuxt: v2.15.8
- Node: v14.17.1
It is also doubling all calls to nuxt.hooks and running the modules and build modules twice (those using "generate.before" in my case)
Thanks for your contribution to Nuxt! This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you would like this issue to remain open:
- Verify that you can still reproduce the issue in the latest version of nuxt-edge
- Comment the steps to reproduce it
Issues that are labeled as pending
will not be automatically marked as stale.
This should open again