-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
54 lines (47 loc) · 1.35 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
var gulp = require('gulp');
var g = require('gulp-load-plugins')();
var optimize = (g.util.env.optimize ? true : false);
var config = require('./package.json')
var autoprefixer = require('gulp-autoprefixer');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var pxtorem = require('gulp-pxtorem');
gulp.task('js', function () {
return gulp.src(config.compile.js.src)
.pipe(g.include())
.on('error', g.util.log)
.pipe(g.if(optimize, g.uglify({
mangle: false,
})))
.on('error', g.util.log)
.pipe(g.size())
.pipe(gulp.dest(config.compile.js.dest))
});
gulp.task('css', function() {
return gulp
.src(config.compile.css.src)
.pipe(sourcemaps.init())
// Sass
.pipe(sass({outputStyle: optimize ? 'compressed' : 'expanded',
includePaths: config.compile.css.paths
}))
.on('error', g.util.log)
// Autoprefixer
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
// PX to REM
.pipe(pxtorem())
.pipe(g.size())
// SCSS Source Maps
.pipe(sourcemaps.write('./scss/maps'))
// CSS output folder
.pipe(gulp.dest(config.compile.css.dest))
});
gulp.task('build',['css','js'],function(){
})
gulp.task('watch', function() {
gulp.watch(config.compile.css.watch, ['css']);
gulp.watch(config.compile.js.watch, ['js']);
});