[英]Make the Webpack React Fast Refresh plugin ignore linting errors
I am using this plugin for HMR: https://www.npmjs.com/package/@pmmmwh/react-refresh-webpack-plugin .我正在为 HMR 使用这个插件: https://www.npmjs.com/package/@pmmmwh/react-refresh-webpack-plugin 。
How can I stop it from preventing the page from displaying for non-breaking errors?如何阻止它阻止页面显示非破坏性错误?
For example linting issues.例如掉毛问题。
My setup is pretty much copied from their example:我的设置几乎是从他们的示例中复制的:
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
const webpack = require('webpack');
// ... your other imports
const isDevelopment = process.env.NODE_ENV !== 'production';
module.exports = {
// It is suggested to run both `react-refresh/babel` and the plugin in the `development` mode only,
// even though both of them have optimisations in place to do nothing in the `production` mode.
// If you would like to override Webpack's defaults for modes, you can also use the `none` mode -
// you then will need to set `forceEnable: true` in the plugin's options.
mode: isDevelopment ? 'development' : 'production',
module: {
rules: [
// ... other rules
{
test: /\.[jt]sx?$/,
exclude: /node_modules/,
use: [
// ... other loaders
{
loader: require.resolve('babel-loader'),
options: {
// ... other options
plugins: [
// ... other plugins
isDevelopment && require.resolve('react-refresh/babel'),
].filter(Boolean),
},
},
],
},
],
},
plugins: [
// ... other plugins
isDevelopment && new webpack.HotModuleReplacementPlugin(),
isDevelopment && new ReactRefreshWebpackPlugin(),
].filter(Boolean),
// ... other configuration options
};
我在 API 文档中遗漏了这一点:
new ReactRefreshWebpackPlugin({ overlay: false })
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.