使用nuxt时可以关闭热重载吗?

问题描述 投票:0回答:3

我启动了我的 vue/nuxt 应用程序:

npx create-nuxt-app 

我想在运行开发服务器时关闭热重载功能。我在任何地方都找不到执行此操作的选项。 nuxt命令的帮助中有:

nuxt --help
    Description
      Starts the application in development mode (hot-code reloading, error
      reporting, etc)
    Usage
      $ nuxt dev <dir> -p <port number> -H <hostname>
    Options
      --port, -p          A port number on which to start the application
      --hostname, -H      Hostname on which to start the application
      --spa               Launch in SPA mode
      --universal         Launch in Universal mode (default)
      --config-file, -c   Path to Nuxt.js config file (default: nuxt.config.js)
      --help, -h          Displays this message

没有关闭热重载的开关。我认为在

nuxt.config.js
文件中可能有可能,但我一直无法找到可能的选项。

我已经浏览了从此页面开始的文档:https://nuxtjs.org/api/configuration-build但我没有看到它。

vuejs2 nuxt.js
3个回答
0
投票

这不是下面的完美解决方案,但至少它停止了热重载。

对于使用 Webpack 3 和 Chrome (67.0.3396.99) DevTools 的 Nuxt 1.4.0:

  1. 在 Chrome 中打开开发者工具
  2. 单击右上角的三个点 (...)
  3. 点击更多工具 -> 请求阻止
  4. 点击“启用请求阻止”并添加“*hot-update.json”

这将停止热重载 - 但也会抛出错误消息。

可能对某人有帮助 - 它对我有用:)


0
投票

我认为回答这个问题有点晚了,但是将其添加到 nuxt.config.js 将会起作用

  build: {
      extend(config) {
          const hmrIndex = config.plugins.findIndex(p => p.constructor.name === 'HotModuleReplacementPlugin')
          config.plugins.splice(hmrIndex, 1)
      }
  }

因此,它的行为方式是,它将在更改时重新编译,但不会刷新页面。如果您在浏览器上手动刷新,新的更改将得到反映。

如果这就是OP正在寻找的东西,我不是......


-2
投票

在你的 nuxt.config.js 中

[![module.exports = {
...
  output: {
    publicPath: ''
  },
...
}

这是解决方案并查看线程中的讨论以了解更多

imageref

© www.soinside.com 2019 - 2024. All rights reserved.