Answer the question
In order to leave comments, you need to log in
Is there any way to universally add files?
There is a plugin
new HandlebarsPlugin({
// path to main hbs template
entry: path.join(process.cwd(), "app", "src", "index.hbs"),
// filepath to result
output: path.join(process.cwd(), "build", "index.html")
})
Answer the question
In order to leave comments, you need to log in
Scan a directory, get a list of files, and create as many plugin instances as there are in the folder:
var glob = require('glob');
var files = glob.sync('lib/*.js');
...
plugins: files.map(function(filepath) {
var basename = path.basename(filepath);
var basenameWithoutExtension = basename.substr(0, basename.lastIndexOf("."));
return new HandlebarsPlugin({
entry: path.resolve(process.cwd(), filepath),
output: path.join(process.cwd(), 'build', basenameWithoutExtension + '.html')
});
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question