Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ module.exports = function(content) {
if (opt.raw) {
callback(null, content);
} else {
callback(null, "module.exports = " + JSON.stringify(content));
content = "module.exports = " + JSON.stringify(content)
content = content.replace(
/__WEBPACK_TEMPLATE_HTML_LOADER__\(([^\)]+)\)/g,
'" + require("$1") + "'
)
callback(null, content);
}
}

Expand All @@ -28,6 +33,16 @@ module.exports = function(content) {

// for relative includes
opt.filename = this.resourcePath;
opt.require = function(path) {
this.addDependency(path)
// Adding the default !file! loader for requires without a loader specified.
// This will create links to assets (images, etc.) without a module.exports=
// prefix at the top of the asset file.
if (path.match(/^\-?\!/) === null) path = "!file!" + path
// Substituting a placeholder string for the require. This will be replaced
// with an actual call to the require function in the generated javascript
return "__WEBPACK_TEMPLATE_HTML_LOADER__("+path+")"
}.bind(this)

cons[opt.engine].render(content, opt, function(err, html) {
if(err) {
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
"dependencies": {
"consolidate": "~0.10.0",
"loader-utils": "~0.2.1"
},
"peerDependencies": {
"file-loader": "*"
}
}