webpack错误记录(不定期更新)
发布日期:2021-06-29 15:52:09 浏览次数:3 分类:技术文章

本文共 1679 字,大约阅读时间需要 5 分钟。

文章目录

CleanWebpackPlugin相关

CleanWebpackPlugin is not a constructor

更新记录

date: 2020-12-31 初始化错误记录

代码

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: 'Output Management' }) ], output: {
filename: '[name].bundle.js', path: path.resolve(__dirname, 'dist') } };

错误信息

[webpack-cli] Failed to load 'D:\workplace\前端\learnWebpack\demo1\webpack.config.js'[webpack-cli] Error: clean-webpack-plugin only accepts an options object. See:            https://github.com/johnagan/clean-webpack-plugin#options-and-defaults-optional    at new CleanWebpackPlugin (D:\workplace\前端\learnWebpack\demo1\node_modules\clean-webpack-plugin\dist\clean-webpack-plugin.js:27:13)

版本信息

  • webpack 5.11.1
  • webpack-cli 4.3.0
  • CleanWebpackPlugin 3.0.0

错误原因

新版本插件语法发生变化,不要在函数里面传递参数就行

new CleanWebpackPlugin()

参考资料

webpack.config.js

Automatic publicPath is not supported in this browser

修改记录

date: 2020-12-31 初始化记录

问题描述

使用html-loader处理html文件中的图片引入,webpack执行报错

ERROR in   Error: D:\workplace\前端\learnWebpack\packageImg\src\index.html:97  /******/  if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");                            ^  Error: Automatic publicPath is not supported in this browser

解决方法

webpack,config.js文件中配置 output.publicPath

output:{
filename:'built.js', path:resolve(__dirname,'build'), publicPath:'./' },

参考文件

转载地址:https://console.blog.csdn.net/article/details/112003961 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:Poj百练 2692:假币问题 (分类:模拟)
下一篇:vue的一些基础知识点

发表评论

最新留言

能坚持,总会有不一样的收获!
[***.219.124.196]2024年04月25日 21时38分34秒