0
我在反应项目中工作。当我使用“exclude:/ node_modules”时,我的项目并未排除node_modules。所以我读了一些解决的问题,并将下面的代码添加到我的webpack.config.js中。在浏览器控制台中使用“externals”排除node_modules错误
var nodeExternals = require('webpack-node-externals');
...
module.exports = {
...
target: 'node', // in order to ignore built-in modules like path, fs, etc.
externals: [nodeExternals()], // in order to ignore all modules in node_modules folder
...
};
我webpack.config.js则看起来像这样
var path = require('path');
var webpack = require('webpack');
var nodeExternals = require('webpack-node-externals');
module.exports = {
devtool: 'eval',
entry: [
'webpack-dev-server/client?http://localhost:3000',
'webpack/hot/only-dev-server',
'./dev/js/index.js'
],
target: 'node', // in order to ignore built-in modules like path, fs, etc.
externals: [nodeExternals()], // in order to ignore all modules in node_modules
module: {
loaders: [
{
test: /\.js$/,
loaders: ['react-hot', 'babel'],
exclude: /node_modules/
},
{
test: /\.scss/,
loader: 'style-loader!css-loader!sass-loader'
}
]
},
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js',
publicPath: '/static/'
},
plugins: [
new webpack.HotModuleReplacementPlugin()
]
};
当我运行我的应用程序,我在控制台收到此错误
我怎样才能解决这个问题错误?
所以我应该删除它 – ApurvG
是的,你不应该需要这个模块的浏览器包。 –
但是为什么浏览器控制台热载入程序会说更新了576个模块,每当我对组件进行更改时。为什么每次更新很多模块?这意味着节点模块每次都会更新。我应该怎么做? – ApurvG