Error: clean-webpack-plugin only accepts an options object.
最近在学习Webpack,在plugins 中调用clean-webpack-plugin 的时候报错,
译:https://github.com/johnagan/clean-webpack-plugin
转:https://stackoverflow.com/questions/55190450/clean-webpack-plugin-only-accepts-an-options-object
源码
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
module.exports = {entry:{app:'./src/index.js',print:'./src/print.js',},plugins:[new CleanWebpackPlugin(['dist']),new HtmlWebpackPlugin({title:'Hello, kankan.'})],output:{filename:'[name].bundle.js',path: path.resolve(__dirname,'dist')},};
Error
Error: clean-webpack-plugin only accepts an options object. See:https://github.com/johnagan/clean-webpack-plugin#options-and-defaults-optionalat new CleanWebpackPlugin
Solution
CleanWebpackPlugin 不需要参数
可以尝试下面的语法,
new CleanWebpackPlugin()
对于错误,要认真看所用的插件版本,自学习的时候可能是用的最新代码库和插件,在运行教程或者教材上面的命令的时候要慎重,有些新的插件函数或者库有所改动,导致一些语法和命令产生了变化,以至于编译出错.
学习也是一个思考的过程,思考蕴含的原理。
几个有趣的案例:
怦然心动表白画轴:https://blog.csdn.net/qq_38025939/article/details/89365800
阴阳日历:https://blog.csdn.net/qq_38025939/article/details/89351585
个人主页:https://kankan.fun
明天的一定会感谢现在拼命的自己!