admin管理员组文章数量:1315079
Webpack, super cool and great, yay
also running it with grunt-webpack, omg so happy
whats more? some nice fellow made an inliner so I can require .html files, I sure am lucky
var html = require("html!./some_template.html");
only troublesome detail is that an html file containing
<h3><%= any_variable %></h3>
es out as
module.exports = "<h3><%= any_variable %></h3>"
I feel like I must be missing some silly detail, otherwise maybe the thing to do is alter html-loader? It's a fairly trivial detail but I still feel like I'm misunderstanding this tool.
check it out .js
as requested, from webpack.config.js, or in my case Gruntfile.js
module: {
loaders: [
{ test: /\.html$/, loader: "html" }
]
}
SOLUTION: turns out I can't actually read, require("html!./some_template.html");
runs the loader, and then I was also running it in my config, so I wound up with monjs declaration in my html.
Webpack, super cool and great, yay
also running it with grunt-webpack, omg so happy
whats more? some nice fellow made an inliner so I can require .html files, I sure am lucky
var html = require("html!./some_template.html");
only troublesome detail is that an html file containing
<h3><%= any_variable %></h3>
es out as
module.exports = "<h3><%= any_variable %></h3>"
I feel like I must be missing some silly detail, otherwise maybe the thing to do is alter html-loader? It's a fairly trivial detail but I still feel like I'm misunderstanding this tool.
check it out https://github./webpack/html-loader/blob/master/index.js
as requested, from webpack.config.js, or in my case Gruntfile.js
module: {
loaders: [
{ test: /\.html$/, loader: "html" }
]
}
SOLUTION: turns out I can't actually read, require("html!./some_template.html");
runs the loader, and then I was also running it in my config, so I wound up with monjs declaration in my html.
- 1 Can you show the loader part of your webpack config? – Spencer Alger Commented Jun 12, 2015 at 7:23
2 Answers
Reset to default 8For others who are struggling like me here's the solution - https://www.reddit./r/javascript/ments/39jp8z/webpack_weirdness_no_love_at_stackoverflow/
Basically the html-loader is running twice!!
Remove either of the setting. (in webpack config or while importing)
It is explicitly coded to do that - https://github./webpack/html-loader/blob/master/index.js#L71
You could contact the author through github and/or file an issue there?
本文标签: javascriptWebpack htmlloader returns full module definitionStack Overflow
版权声明:本文标题:javascript - Webpack html-loader returns full module definition - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741971503a2407866.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论