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

fix: recompile parent template automatically when child template is changed #58

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from
Open
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
16 changes: 14 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ module.exports = function (source) {

// wepkack3: options
var options = utils.getOptions(this);
// merge opts from defaults,opts and query

// merge opts from defaults,opts and query
var opts = merge({
client: true,
compileDebug: !!this.minimize,
Expand All @@ -24,6 +24,18 @@ module.exports = function (source) {
// minify html
if (opts.htmlmin) source = htmlmin.minify(source, opts.htmlminOptions);

// Build open delimiter from options
const delim = opts.delimiter || "%";
const open = opts.openDelimiter || "<";
let openDelimiter = "<%".replace(/%/g, delim).replace(/</g, open)

// Find included files and add them to webpack dependencies
let regexp = new RegExp(`${openDelimiter}-\\sinclude\\s+(\\S+)`, "gi");
const array = [...source.matchAll(regexp)];
array.forEach(([match, link]) => {
this.addDependency(path.resolve(this.context, link))
});

// compile template
var template = ejs.compile(source, merge(opts, {
filename: path.relative(process.cwd(), this.resourcePath),
Expand Down