Easily scan your project directories to generate a structured list of your templates and their associated assets.
npm install template-structure-generator --save-dev
Simply integrate the plugin into your Webpack configuration. Specify the directory with the required file extensions and provide a template structure for the output.
const TemplateStructureGeneratorPlugin = require('template-structure-generator');
module.exports = {
plugins: [
new TemplateStructureGeneratorPlugin({
directoryGlob: 'src/pages/*.html',
outputDirectory: '.template-structure',
outputFileName: 'templateList.js',
template: {
js: ['common.js'],
scss: ['common.scss'],
},
}),
],
};
Upon execution, the script will traverse the specified directory and generate an output of all discovered templates, adhering to the provided structure:
Output example (./.template-structure/templateList.js):
module.exports = {
'index.html': {
js: ['common.js'],
scss: ['common.scss'],
},
'detail.html': {
js: ['common.js'],
scss: ['common.scss'],
},
};
Feel free to submit issues or pull requests if you find any bugs or have suggestions for improvements.