错误:
Html插件:错误: Webpack ://AC.26/data:text/javascript,webpack_public_path_=webpack_base_uri=_htmlWebpackPl uginPublicPath;?:2 webpack_require.p = webpack_base_uri = htmlWebpackPluginPublicPath;^
ReferenceError: webpack_base_uri未定义为
webpack_public_path_=webpack_base_uri=htmlWebpackPluginPublicPath;?:2
,
我不知道为什么会发生这种事,我也读过很多博客,但是很少有关于它的博客,我确实想用it.Please来帮助我。
代码↓
var webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const htmlPlugin = new HtmlWebpackPlugin({
template:'./src/index.html',
filename:'index.html',
})
module.exports = {
mode:"development",
entry:path.join(__dirname,'./src/index.js'),
output:{
path:path.join(__dirname,'./dist'),
filename:'bundle.js'
},
plugins:[htmlPlugin]
}
package.json
{
"name": "webpack",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "webpack-dev-server --open --host --127.0.0.1 --port 8888"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"jquery": "^3.6.0"
},
"devDependencies": {
"css-loader": "^5.2.4",
"html-webpack-plugin": "^5.3.1",
"style-loader": "^2.0.0",
"vue": "^2.6.12",
"webpack": "^4.46.0",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.1.14"
}
}
发布于 2021-10-31 11:43:53
这个问题是因为html-webpack-plugin
,它目前要求一个对等的"webpack": "^5.20.0"
,但是__webpack_base_uri__
是在5.21.0中添加的。
https://webpack.js.org/api/module-variables/#__webpack_base_uri__-webpack-specific
要快速修复,您可以将您的webpack.config.js放在__webpack_base_uri__ = 'http://localhost:8081';
顶部
Nota:端口是提供devServer的地方
发布于 2021-04-27 12:14:45
尝试在webpack配置中添加插件:
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('development')
})
],
https://stackoverflow.com/questions/67282705
复制相似问题