new SuppressChunksPlugin([
^
类型错误:抑制块插件不是构造函数 在对象。(/Users/rohit/WebstormProjects/myProjectStructure/webpack.config.js:80:9( 在Module._compile(模块.js:570:32( 在Object.Module._extensions..JS(模块.js:579:10( at Module.load (module.js:487:32( at tryModuleLoad (module.js:446:12( 在Function.Module._load(模块.js:438:3( at Module.require (module.js:497:17( 在要求(内部/模块.js:20:19( at requireConfig (/usr/local/lib/node_modules/webpack/bin/convert-argv.js:97:18( at/usr/local/lib/node_modules/webpack/bin/convert-argv.js:104:17
下面是 Web 配置文件。
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var SuppressChunksPlugin = require('suppress-chunks-webpack-plugin');
module.exports = {
context: path.resolve(__dirname, './src'),
entry: {
blitz: './blitz.js',
},
output: {
path: path.resolve(__dirname, './dist/assets'),
filename: '[name].bundle.js'
},
module: {
rules: [
{
test: /.less$/,
use: ExtractTextPlugin.extract({
// use style-loader in development
fallback: 'style-loader',
use: 'css-loader?minimize!less-loader'
})
},
{
test: /.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use:'css-loader?minimize'
})
}
]
},
plugins:[
new ExtractTextPlugin('[name].css'),
new SuppressChunksPlugin([
{name: 'blitz', match: /.js$/},
])
]
};
suppress-chunks-webpack-plugin
使用 ES 模块,并且只有一个默认导出(另请参阅转译的源 unpkg - suppress-chunks-webpack-plugin(。
要将其与 Node 的require
一起使用,您需要访问default
属性。
var SuppressChunksPlugin = require('suppress-chunks-webpack-plugin').default;