Generation of files in gulp. Automation of build processes?

To automate the processes you want to implement in Assembly [gulp + webpack (only js)] automatic creation of the necessary files.

What you need: in the pages folder are *.pug || *.the html files of the pages layout. When you add any file in this folder, you need to make auto generate file in a different folder controllers approx. pagename.controller.js. Which will have to lie boilerplate code.

An example of the structure:
pages
- about.pug
controllers
- about.controller.js

After adding a file store.pug in the pages folder.

pages
- about.pug
- store.pug
controllers
- about.controller.js
- store.controller.js - automatically generated file with already nieuwsma boilerplate code.

Question.
1. In what side to dig, in terms of ready-made solutions, materials.
2. If you use the plugin to create files using gulp, how is the logic of automatic substitution of the imports in the files you need? Or must hang on a new file listener gulp?
April 4th 20 at 00:38
2 answers
April 4th 20 at 00:40
Solution
Google this way

const gulp = require('gulp');
const fs = require('fs');
const path = require('path');

const watcher = gulp.watch('./pages', { events: ['add'] });

watcher.on('add', function(p, stats) {
 const name = path.basename(p, path.extname(p));
 fs.writeFileSync(`./controllers/${name}.controller.js`, 'what is in the file');
});


+ a bunch of checks

PS: while normal people do it through console commands, such as laravel
php artisan make:controller PhotoController
April 4th 20 at 00:42
Perhaps not entirely, but none the less it looks like - link

Find more questions by tags JavaScriptAssembling projectsGulp.jsWebpack