如何为中微子项目禁用Webpack开发服务器自动重新加载?

时间:2018-08-29 08:42:28

标签: node.js webpack webpack-dev-server neutrino

  • 浏览器:仔细阅读
  • 项目类型:SAFE网络网站

我需要将其关闭,因为Peruse认为window.eval()是一个安全问题,因此将其阻止,从而导致我的网站无法加载。

据我所知,Peruse是Maidsafe的标准浏览器。

我修复此问题的两次尝试均失败:

webpack.config.js

module.exports = {
  devServer: {
    hot: false,
    inline: false
  }
};

neutrinorc.js

module.exports = {
  use: [
    [
      '@neutrinojs/vue',
      {
        html: {
          title: 'SAFE Web App'
        }
      }
    ],
    (neutrino) => {
      neutrino.config.devServer
        .hot(false)
        .inline(false)
    }
  ]
};

错误:

Uncaught Error: Sorry, peruse does not support window.eval().
    at window.eval.global.eval (/opt/Maidsafe/Peruse/resources/app.asar/webPreload.js:9:82219)
    at Object../node_modules/webpack-dev-server/client/index.js?http://localhost:5000 (http://localhost:5000/index.js:957:1)
    at __webpack_require__ (http://localhost:5000/index.js:679:30)
    at fn (http://localhost:5000/index.js:89:20)
    at Object.0 (http://localhost:5000/index.js:1060:1)
    at __webpack_require__ (http://localhost:5000/index.js:679:30)
    at http://localhost:5000/index.js:725:37
    at http://localhost:5000/index.js:728:10

package.json

  ...
  "dependencies": {
    "@babel/helper-module-imports": "^7.0.0-beta.44",
    "vue": "^2.5.16"
  },
  "devDependencies": {
    "@neutrinojs/vue": "^8.2.1",
    "@vue/devtools": "^4.1.5",
    "neutrino": "^8.2.1"
  }
  ...

1 个答案:

答案 0 :(得分:0)

eval()错误不是来自webpack-dev-server。

事实证明,@neutrinojs/web继承的@neutrinojs/web使用的默认源映射模式是cheap-module-eval-source-map,需要将其设置为cheap-module-source-map

因此 neutrinorc.js 需要这样配置:

module.exports = {
  use: [
    ['@neutrinojs/vue', {
      // Existing options
    }],
    (neutrino) => {
      if (process.env.NODE_ENV === 'development') {
        // Override the default development source map of 'cheap-module-eval-source-map'
        // to one that doesn't use `eval` (reduces incremental build performance).
        neutrino.config.devtool('cheap-module-source-map');
      }
    }
  ]
};