Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在html-webpack-plugin模板里使用 #7

Open
jqjiang opened this issue Dec 9, 2016 · 9 comments
Open

在html-webpack-plugin模板里使用 #7

jqjiang opened this issue Dec 9, 2016 · 9 comments

Comments

@jqjiang
Copy link

jqjiang commented Dec 9, 2016

在html-webpack-plugin这么配置:
template: 'html-withimg-loader!' + filePath,
filename: filename + '.html'
在loaders这么配置:
{
test: /.(jpg|png)$/,
loader: 'url',
query: {
limit: 8192,
name: '[name].[ext]?[hash:7]'
}
},
但是没有任何作用,也不报错是为什么

@wzsxyz
Copy link
Owner

wzsxyz commented Dec 12, 2016

limit改为1试试呢
如果不行,可能就是访问的资源路径不对,需要访问publicPath配置路径下的资源才是编译后的,
比如:output:{publicPath:‘__build’},那么url就该是 127.0.0.1:????/__build/页面

@songyazhao
Copy link

plugins: [
    new htmlWebpackPlugin({
        filename: 'index.html',
        template: 'html-withimg-loader!index.html',
        title: 'this is index.html!!'
    })
]

使用了这个之后我在 template 要取一些属性,比如 <%= htmlWebpackPlugin.options.title %> 但是它没有被转译,而是被原样输出了,有什么解决方案不

image

@yoyo837
Copy link

yoyo837 commented Mar 21, 2017

@wzsxyz 我用的是ejs模板,和 @songyazhao 一样的疑问,请问如何处理?

@nikolausliu
Copy link

@songyazhao 我也遇到了 <%= htmlWebpackPlugin.options.title %>,不转译直接输出的问题了,请问你这里是怎么解决的呢?这个loader还挺好用的,但是作者貌似不维护了啊

@xiao252
Copy link

xiao252 commented Apr 16, 2020

@songyazhao 同样的问题,

@virtueDe
Copy link

virtueDe commented Aug 6, 2020

@songyazhao 同样的问题 请问怎么解决

@xiao252
Copy link

xiao252 commented Aug 6, 2020

@songyazhao 同样的问题 请问怎么解决

github搜索html-webpack-plugin 有个针对这个问题的修复版

@virtueDe
Copy link

@xiao252 俺没找到 老哥恰个链接?

@xiao252
Copy link

xiao252 commented Aug 15, 2020

@xiao252 俺没找到 老哥恰个链接?

https://github.com/ysk2014/inline-html-withimg-loader

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants