webpack - 带有 publicPath 的 Webpack 资产生成器不起作用?
问题描述
将 webpack 升级到 5.64.0 版本时,module.rule.generator.publicPath
已停止正常工作。
module.exports={
// ....,
generator: {
filename: devMode
? "../fonts/[name][ext][query]"
: "fonts/[name][hash][ext][query]",
publicPath: "fonts",
},
}
我有这个错误:
ERROR in ./src/frontlib.sass
Module build failed (from ./node_modules/mini-css-extract-plugi/dist/loader.js):
HookWebpackError: Invalid URL at tryRunOrWebpackError
现在即使我将 Webpack 降级到以前的版本,我仍然有同样的错误。
如何将生成器设置publicPath
为新的 Webpack 版本?
解决方案
我有同样的问题,但我得到了它的工作。生成器不支持 publicPath。您必须使用编译器的输出。
...
entry: {
main: './src/inputFile.js'
},
output: {
filename: 'outputName.js',
path: path.resolve(__dirname, '../outputFolder')
}
...
{
test: /.(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
type: "asset/resource",
generator: {
filename: './fonts/[hash][ext]'
}
}
我在这个仓库中有一个例子: https ://github.com/Vanillabacke/webpack-5-settings
推荐阅读
- tensorboard - 如何在张量板上跟踪训练有素的张量流对象检测 api 的准确性
- typescript - Typescript如何检查具有多种类型的对象的类型
- python - UDP客户端错误:ConnectionResetError:[WinError 10054]一个现有的连接被远程主机强行关闭
- android - Android复选框在recyclerview中的片段上不可点击
- python-3.x - 我从 Heroku 收到关于 Discord Intents 的错误 (Discord.py)
- magnolia - Magnolia 版本中的隐藏操作是 5.7
- python - django 中的匿名用户多对多领域
- python - 按可用性回顾性地遍历不同的时间序列
- java - 我正在尝试在底部导航中添加 tablayout,但片段中未设置适配器,为什么?
- css - 带有网格输入的样式化组件