那些年踩过的坑

webpack-html-plugin filename 配置的一个坑

问题描述:想要经过filename来配置打包时生成html文件的子路径。代码配置以下:html

filename: subpath ? `${subpath}${pageName}.html` : ''

其中传入的subpath参数为 test/webpack

运行构建时报错以下:web

image.png

一开始看报错提示觉得是权限的问题致使的,怎么修改权限也没有用。最后偶然把webpack修改成:spa

filename: subpath ? `${subpath}${pageName}.html` : `{pageName}.html`

构建成功。code

总结 filename参数不能够给传空字符串htm

相关文章
相关标签/搜索