nuxt.js 热重载很慢

jbt*_*bty 7 nuxt.js

我想知道nuxt需要2或3秒才能进行热重载更改是否正常?例如,对于 Gatsby,Hot Reloads 是即时的。我错过了什么?

这是我的 nuxt 构建配置:

build: {
    parallel: true,
    cache: true,
    extractCSS: process.env.NODE_ENV === 'production',
    optimizeCSS: process.env.NODE_ENV === 'production',
    transpile: ['vue-intersect'],
},

Run Code Online (Sandbox Code Playgroud)

Hen*_*ren 9

我认为你的问题是因为你有一个属性components设置为true

  • Nuxt.js 2.13+ 可以扫描并自动导入你的组件。但默认情况下,此选项设置为 false。您不需要将其设置为 true。

当设置为 true 或使用对象时,它将包含 nuxt/components 依赖项,并在您在模板中使用它们时自动导入您的组件(在 ~/components 中定义)。

...
// change to false, or remove this config.
components: true
...
Run Code Online (Sandbox Code Playgroud)

仅当您知道为什么需要将此属性设为 true 时才设置为 true。因此,您可以在 Nuxt 文档https://nuxtjs.org/api/configuration-components和 Github 文档https://github.com/nuxt/components 中找到更多相关信息。

  • 哇,谢谢,我的构建每次热重载大约需要 20-30 秒。将组件更改为 false 后,只需不到一秒钟! (3认同)