webpack - clean-webpack-plugin 只接受一个选项对象
问题描述
我越来越
错误:clean-webpack-plugin 只接受选项对象。请参阅: https ://github.com/johnagan/clean-webpack-plugin#options-and-defaults-
我的 Webpack.config.js 文件如下所示:
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
var plugins = [
new CleanWebpackPlugin(['dist'], {}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new CopyWebpackPlugin([{
from: './src/images/',
to: './images/'
}]),
new HtmlWebpackPlugin({
inject: false,
template: 'src/index.html'
})
];
var config = {
entry: [
'./src/js/main.js'
],
output: {
path: path.join(__dirname, 'dist'),
publicPath: '/',
filename: 'js/bundle.js',
},
plugins: plugins.concat([
new ExtractTextPlugin('css/bundle.css'),
//new webpack.optimize.UglifyJsPlugin(require('./uglifyjs.json'))
]),
devServer: {
inline: true,
port: 8080
},
module: {
loaders: [{
test: /\.jsx?$/,
exclude: /node_modules/,
include: path.join(__dirname, 'src'),
loader: 'babel',
query: {
presets: ['react', 'es2015']
}},
{
test: /.s?css$/,
include: path.join(__dirname, 'src'),
loader: ExtractTextPlugin.extract('style', [
'css?sourceMap',
'postcss',
'sass?sourceMap'
])
},
{
test: /\.css$/,
include: path.join(__dirname, 'node_modules'),
loader: 'style!css'
}
]
},
postcss: function() {
return [
require('autoprefixer')({
browsers: ['last 2 versions']
})
];
}
}
module.exports = config;
解决方案
正如您从页面中看到的错误消息链接,CleanWebpackPlugin
在您传入时不接受两个参数:
new CleanWebpackPlugin(['dist'], {}),
相反,只需尝试
new CleanWebpackPlugin(),
如果您不需要传递任何选项。
例如,如果您正在遵循使用不同版本插件的较旧教程或类似的教程,并且界面同时发生了变化,您可能会看到这个问题。
推荐阅读
- javascript - 如何访问函数之外的数据 - Angular/Javascript
- arrays - 遍历散列数组并更新每个散列
- android - 为什么 qemu-system-x86_64 (android 模拟器) 仍在运行
- wso2 - Apache Directory Studio 不显示在 WSO2 IS 用户中新建的
- ios - 如何禁用后退/左滑手势?
- mysql - Laravel Eager Loading 两端都有一些 where 条件
- android - 检测到 Ionic 3 Android Studio
- android - 如何避免在 Google 自定义模板请求中出现错误代码 0?
- reactjs - 从 UI Fabric React 详细信息列表连接不同页面中的两个 Web 部件
- java - 如何将 Postgres COPY 命令的 PROGRAM 子句与 Powershell 命令一起使用