Folaht
Folaht

Reputation: 1123

How to disable webpack dev server auto reload for neutrino project?

I need to turn it off because Peruse considers window.eval() to be a security issue and thus blocks it, which in turn stops my website from loading.

Peruse is the standard browser for Maidsafe as far as I know.

Both of my attempts to fix this have failed:

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)
    }
  ]
};

The error:

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"
  }
  ...

Upvotes: 3

Views: 1592

Answers (1)

Folaht
Folaht

Reputation: 1123

The eval() errror is not coming from webpack-dev-server.

It turns out that the the default source map mode used by @neutrinojs/web which @neutrinojs/web inherits from is cheap-module-eval-source-map and needs to be set to cheap-module-source-map.

Thus neutrinorc.js needs to be configured as such:

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');
      }
    }
  ]
};

Upvotes: 1

Related Questions