Webpack html-loader returns complete module definition
Webpack, super cool and great, yay
also runs it with grunt-webpack, omg so happy
what else? some nice guy made an inliner so i can require .html files i'm lucky
var html = require("html!./some_template.html");
the only tricky detail is that the html file containing
<h3><%= any_variable %></h3>
appears as
module.exports = "<h3><%= any_variable %></h3>"
I feel like I must be missing some silly details, otherwise what needs to be done is change the html-loader? This is a pretty trivial detail, but I still feel like I don't understand this tool.
check out https://github.com/webpack/html-loader/blob/master/index.js
on request, from webpack.config.js or in my case Gruntfile.js
module: {
loaders: [
{ test: /\.html$/, loader: "html" }
]
}
SOLUTION: It turns out that I am not able to read, require("html!./some_template.html");
starts the loader and then I also run it in my config, so I got the commonjs declaration in my html.
source to share
For those struggling like me here, the solution is https://www.reddit.com/r/javascript/comments/39jp8z/webpack_weirdness_no_love_at_stackoverflow/
Basically the html downloader works twice!
Delete the setting. (in webpack config or on import)
source to share
This is clearly coded for this - https://github.com/webpack/html-loader/blob/master/index.js#L71
Can you reach the author via github and / or file an issue there?
source to share