I'm trying to create a loader which will just parse the content for this syntax:
{{ 'assets/someimage.png'|theme }}
every matches should be added as a webpack dependency from the root webpack directory without making any change in the final's content (this syntax is needed by the CMS template)
Here is where I've been:
let path = require('path'),
themeRegex = /\{\{[\s?]*["|'|`](.*[\.[png|jpe?g|gif|ico])["|'|`][\s?]*\|[\s?]*theme[\s?]*\}\}/g;
module.exports = function (content, map, meta) {
while ((themeFilterRequest = themeRegex.exec(content)) !== null) {
var srcPath = path.join(this.rootContext, 'src')
this.resolve(srcPath, './'+themeFilterRequest[1], (err, result) => {
if (err) throw err
console.log(result)
})
}
return 'module.exports = [\n' +
JSON.stringify(content) +
'\n].join();'
};
but for now, the file isn't loaded, at the right place. It actually is created in my dist folder but only contain the text "assets/someimage.png" in the png extension file...
How to binary load the file?
Thanks!