Javascript 使用IgnorePlugin的Webpack生成webpackMissingModule错误
我正在尝试从包中删除angular.js。找不到从bundle.js中删除它的方法,因为Webpack以某种方式从我的条目文件中解析了它。所以我决定使用Javascript 使用IgnorePlugin的Webpack生成webpackMissingModule错误,javascript,webpack,Javascript,Webpack,我正在尝试从包中删除angular.js。找不到从bundle.js中删除它的方法,因为Webpack以某种方式从我的条目文件中解析了它。所以我决定使用webpack.IgnorePlugin,但结果我收到了错误 找不到模块“angular” 在webpackMissingModule 在bundle.js加载之前,我已经包含了cdn中的angular js。但它仍然试图从网页包脚本中解决它 webpack.make.js module.exports = function makeWebpac
webpack.IgnorePlugin
,但结果我收到了错误
找不到模块“angular”
在webpackMissingModule
在bundle.js加载之前,我已经包含了cdn中的angular js。但它仍然试图从网页包脚本中解决它
webpack.make.js
module.exports = function makeWebpackConfig(options) {
var config = {};
config.entry = {
app: './app/app.js'
}
config.output = {
path: __dirname + '/public',
publicPath: BUILD ? '/' : 'http://localhost:8080/',
filename: 'bundle.js',
chunkFilename: 'bundle.js',
}
...
config.module = {
loaders: [{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
}, {
test: /\.html$/,
loader: 'raw'
}]
};
config.plugins = [
new webpack.IgnorePlugin(/angular$/),
];
...
return config;
};
如果您在应用程序中使用Angular,但不希望webpack包含它,因为它将来自其他地方,您可以将其设置为外部库,webpack不会加载它 它是一个顶级数组配置,指定要在捆绑包中忽略的lib
module.exports = {
externals: ['angular']
}
然后,您可能可以摆脱ignore插件,而不必处理配置的额外部分