我不确定这里的确切问题是什么,但我也有这个警告并通过在 Webpack 配置文件中设置 mode 属性来解决它们
package.json
{
"name": "my-awesome-project",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "NODE_ENV=production webpack",
},
...
"devDependencies": {
...
},
"dependencies": {
...
}
}
webpack.config.js
const path = require('path');
const HtmlWebPackPlugin = require('html-webpack-plugin');
const distDir = path.join(__dirname, 'dist');
const config = {
mode: 'development',
entry: ['./src/js/app.js'],
output: {
path: distDir,
filename: 'js/[name].js',
},
module: {
rules: [
...
]
},
plugins: [
...
],
devtool: "eval-source-map", // Default development sourcemap
};
// Check if build is running in production mode, then change the sourcemap type
if (process.env.NODE_ENV === 'production') {
config.devtool = ''; // No sourcemap for production
config.mode = 'production';
// Add more configuration for production here like
// Uglify plugin
// Offline plugin
// Etc,
}
module.exports = config;
希望对你有帮助。