First, we use Gulp to automate the entry file. We refer to the rules of this course to categorize and organize documents that need to be imported.
First, we have created the SRC folder. Under the src file, create a home folder called modules. A colleague creates several subfolders, and the basic rule is to create a folder name that represents our portal node name.
(this figure is for reference only, folder name and file name can be customized)
Then we came to Gulpfile.js, wrote a task, and traversed the folders and sub-files in the Modules folder in Gulpfile (for demonstration convenience, we traverse level 2 by default.) The first level must be the folder name, the second level must be a JS file.
varWebpack_config = require ("./webpack.config.js"); Gp.task ("Config",function(){ varFS = require ("FS"); varRoot = "./src/modules/"; varconfig = {};//Create an empty object varGet_m = Fs.readdirsync (root);//read the contents of the folder, return an array, here we use synchronous methodGet_m.foreach (function(m) {//Loop through the folder, M is the folder name, also represents the entry node names varGet_m_file = Fs.readdirsync (root+m); varGetret = Get_m_file.map (function(jsfile) {returnroot+m+ "/" +Jsfile; }) Config[m]=Getret; }) Webpack_config.entry=config; //console.log (config);})//Final BuildGp.task ("Run", [' Config '],function() {Webpack (Webpack_config,function(err,status) {//We need some gulp process here . }) /*gp.src (['./src/tpl/!*.html ']). Pipe (Gp.dest ('./build/html '))*/})
Above, we re-wrote the Config method inside the gulpfile.js. Implement Gulp Auto-complete configuration and run Webpack packaging.
Copyright NOTICE: NOTE-taker fugitive pawns love freedom, advocating sharing. But this note stems from www.jtthink.com (programmer in the awkward way) Judging teacher's "front- end development of the rapid study of wealth (nodejs+gulp+webpack Basic Combat)". This study note pawn in the blog Park debut, if need to reprint please respect the teacher Labor, retain judging teacher attribution and course source address.
Previous lesson: "Nodejs+gulp+webpack Basic Combat" course notes (vi)--Additional lessons
"Nodejs+gulp+webpack Basic Combat" course notes (vii)--Using Gulp automatic Configuration "spit" to Webpack execution