1. Create a project in Webstorm console cnpm install--save-dev Gulp cnpm Install--save-dev gulp-concat cnpm Install--save-d EV gulp-minify
2. After the environment configuration is complete, create the src file, place the source index.html,main.js, and other JS files
3. Create a configuration file Gulpfile.js file
/** * Created by Administrator on 2016/11/10.*/Const GULP=require ("Gulp"); Const Minify=require ("Gulp-minify"); Const CONCAT=require ("Gulp-concat"); Const Builddirname= "Build"; Gulp.task ("Copy_html_files",function () { returnGULP.SRC ("src/*.html"). Pipe (Gulp.dest (Builddirname))}); Gulp.task ("Compile_js_files",function () { returnGULP.SRC (["Src/hello.js", "Src/main.js"]). Pipe (Concat ("Index.js") . Pipe (Minify ()). Pipe (Gulp.dest (Builddirname));}); Gulp.task ("Default", ["Copy_html_files", "Compile_js_files"],function () { });/*automatic monitoring of changes in HTML files*/Gulp.watch ("Src/*.html", ["Copy_html_files"]); Gulp.watch ("Src/*.js", ["compile_js_files"]);
View Code
4. Enter gulp at the command line to automatically generate the build folder (including Inde.html,index.js,index-min.js) in the above code
5. Run the index.html in the build folder
Gulp Simple Application