You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be cool if we could use variables with the require and include macros, but it looks like they can only accept string, number, boolean and objects at the moment. For instance, doing this:
@include(htmlWebpackPlugin.options.filename)
results in...
ERROR in Error: Child compilation failed:
Module not found: Error: Can't resolve './NaN' in 'C:\static\outkit-docs\src\templates\docs':
Error: Can't resolve './NaN' in 'C:\static\outkit-docs\src\templates\docs'
Does anyone know of a workaround for this?
The text was updated successfully, but these errors were encountered:
OK, I've investigated the sources a bit, and have found out that object literal (used as second @require argument) is processed by JSON.parse and then by JSON.stringify inside the loader, so should be evaluated somehow before @require is parsed. But as for now, it doesn't seem feasible to me to swap the order of parsing steps or add additional one.
So I have no idea how that feature can be implemented.
A workaround came to me suddenly :) Tricky a bit, and uses portions of the loader's source code as example, but here it is:
<%consttitle='Some '+'title';constheadFileName=htmlWebpackPlugin.options.headFileName||'head.ejs';functionobjExtend(args,obj){args=Array.prototype.slice.call(args);args[0]=Object.assign(obj,args[0]);returnargs;};%><%=require(`./structure/${headFileName}`).apply(null,objExtend(arguments,{ title }))%>
It would be cool if we could use variables with the require and include macros, but it looks like they can only accept string, number, boolean and objects at the moment. For instance, doing this:
results in...
Does anyone know of a workaround for this?
The text was updated successfully, but these errors were encountered: