Skip to content

Commit

Permalink
fix: Ignore handlebars expressions in assets path
Browse files Browse the repository at this point in the history
  • Loading branch information
rokoucha committed Sep 2, 2020
1 parent 325f792 commit 41371dd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
12 changes: 3 additions & 9 deletions index.js
@@ -1,10 +1,4 @@
module.exports = bundler => {
bundler.addAssetType(
"hbs",
require.resolve("parcel-bundler/src/assets/HTMLAsset")
);
bundler.addAssetType(
"handlebars",
require.resolve("parcel-bundler/src/assets/HTMLAsset")
);
module.exports = (bundler) => {
bundler.addAssetType("hbs", require.resolve("./src/HbsAsset"));
bundler.addAssetType("handlebars", require.resolve("./src/HbsAsset"));
};
20 changes: 20 additions & 0 deletions src/HbsAsset.js
@@ -0,0 +1,20 @@
const HTMLAsset = require("parcel-bundler/lib/assets/HTMLAsset");

const handlebarsExpression = (path) => {
return /{{.+}}/.test(path);
};

class HbsAsset extends HTMLAsset {
addDependency(name, options) {
if (!handlebarsExpression(opts.resolved))
return super.addDependency(name, options);
}

processSingleDependency(path, options) {
return handlebarsExpression(path)
? path
: super.processSingleDependency(path, options);
}
}

module.exports = HbsAsset;

0 comments on commit 41371dd

Please sign in to comment.