-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
39 lines (33 loc) · 1.28 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var gulp = require('gulp'),
server = require('gulp-develop-server'),
minifyCSS = require('gulp-minify-css'),
// concat = require('gulp-concat'), // 合并文件
rename = require('gulp-rename'), // 重命名
plugins = require('gulp-load-plugins')();
// 启动
gulp.task('default', ['server','styles','server:restart'], function() {
gulp.watch('./web/public/scss/*.scss', ['styles']);
});
// watch sass change & compile
gulp.task('styles', function() {
gulp.src('./web/public/scss/mantou.scss')
.pipe(plugins.plumber())
.pipe(plugins.sass())
.pipe(gulp.dest('./web/public/css/'));
});
//minify css
gulp.task('minify-css',['styles'], function() {
gulp.src('./web/public/css/mantou.css')
.pipe(gulp.dest('./web/public/css/'))
.pipe(rename({ suffix: '.min' }))
.pipe(minifyCSS({keepBreaks:true}))
.pipe(gulp.dest('./web/public/dist/'))
});
// start express server
gulp.task('server', function() {
server.listen({path: './web/app.js'});
});
// restart server if app.js changed
gulp.task('server:restart', function() {
gulp.watch(['./web/app.js','./web/router.js','./web/controllers/*.js','./web/models/*.js','./web/middlewares/*.js','./web/views/*.hbs','./web/views/partials/*.hbs'], server.restart);
});