1. Install nodejs, build directory, initialize the project
2. Install the plug-gulp-concat
Open a command prompt tool in the project directory
按下 ctrl+r --> 输入 cmd
Installation gulp-concat
npm install gulp-concat --save-dev
It may be slow, wait for some time.
finish installation
3. How to use
- First introduced gulp gulp-concat plug-ins and in the middle of gulpfile.js file in the root directory of the project
- Define a gulp task
//定义一个任务名称 concat
gulp.task('concat',function(){
// 找到src目录下的所有文件夹中的所有js文件
return gulp.src('src/**/*.js')
//执行concat插件方法,合并的js文件,文件名称为 router.js
.pipe(concat('router.js'))
//最后输出到dist/js文件目录下面
.pipe(gulp.dest('dist/js'));
});