首页 > 代码库 > gulp
gulp
基于流的自动化构建工具
//项目目录下执行 npm install gulp //安装依赖 gulp combo.js //压缩文件 npm run build
//package.json文件 { "name": "myname", "version": "1.0", "description": "", "main": "index.js", "scripts": {"build": "gulp combojs && gulp combocss" }, "author": "", "license": "", "devDependencies": { "gulp": "^3.9.1", "gulp-alias-combo": "^0.3.0", "gulp-concat": "^2.6.0", "gulp-minify-css": "^1.2.4", "gulp-ng-annotate": "^2.0.0", "gulp-ngmin": "^0.3.0", "gulp-notify": "^2.2.0", "gulp-rename": "^1.2.2", "gulp-uglify": "^1.5.4" } }
//gulpfile.js文件
var gulp = require(‘gulp‘);
var uglify = require(‘gulp-uglify‘);//js压缩 var concat = require(‘gulp-concat‘);//文件合并 var rename = require(‘gulp-rename‘);//文件更名 var notify = require(‘gulp-notify‘);//提示信息 var cssmin = require(‘gulp-minify-css‘); //压缩css gulp.task(‘combojs‘, function () { return gulp.src([ ‘./angular/angular.js‘, ‘./jquery/jquery.js‘, ‘./js/bootstrap.js‘, ‘./js/bootstrap-switch.js‘, ‘./toastr/toastr.js‘, ‘./js/ui-bootstrap-tpls.min.js‘, ‘./js/tm.pagination.js‘, ‘./js/app.js‘, ‘./js/post.js‘ ]) .pipe(concat(‘all.js‘)) .pipe(gulp.dest(‘./src/js‘)) .pipe(rename({suffix: ‘.min‘})) .pipe(uglify()) .pipe(gulp.dest(‘./src/js‘)); }); gulp.task(‘combocss‘, function () { return gulp.src([ ‘./css/bootstrap.css‘, ‘./css/bootstrap3/bootstrap-switch.css‘, ‘./css/fontello.css‘, ‘./toastr/toastr.css‘, ‘./css/app.css‘ ]) .pipe(concat(‘all.css‘)) .pipe(gulp.dest(‘./src/css‘)) .pipe(rename({suffix: ‘.min‘})) .pipe(cssmin()) .pipe(gulp.dest(‘./src/css‘)); }); gulp.task(‘default‘, [‘combocss‘, ‘combojs‘], function () { console.log(‘gulp完成!‘); });
gulp
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。