-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
75 lines (69 loc) · 2.18 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
var gulp = require("gulp");
var del = require("del");
var rev = require('gulp-rev');
var sass = require("gulp-sass");
var postcss = require("gulp-postcss");
var autoprefixer = require("autoprefixer");
var sourcemaps = require("gulp-sourcemaps");
var sequence = require('run-sequence');
var webpack = require("webpack");
var gulpWebpack = require("gulp-webpack");
var webpackConfig = require("./webpack.config.js");
var livereload = require('gulp-livereload');
/*
Main Tasks
*/
gulp.task("default", function(callback){
sequence('clean', "build-js", "sass", callback);
});
gulp.task("dev", ["default"]);
gulp.task("staging", ["prod"]);
gulp.task("test", ["prod"]);
gulp.task("uat", ["prod"]);
gulp.task("master", ["prod"]);
gulp.task("prod", function(callback){
sequence("clean", "uglify-js", "build-js", "sass", callback);
});
gulp.task("watch", function() {
livereload.listen();
gulp.watch(["frontend/js/**/*.js"], ["build-js"]);
gulp.watch(["frontend/scss/**/*.scss"], ["sass"]);
});
/*
JavaScript Tasks
*/
gulp.task("uglify-js", function(callback){
webpackConfig.plugins = webpackConfig.plugins.concat( new webpack.optimize.UglifyJsPlugin() );
webpackConfig.debug = false;
callback();
});
gulp.task("build-js", function(callback) {
return gulp.src("frontend/js/app.js")
.pipe(gulpWebpack(webpackConfig))
.pipe(rev())
.pipe(gulp.dest('public_html/assets/js'))
.pipe(rev.manifest({path: "public_html/assets/assets.json", merge : true}))
.pipe(gulp.dest(''))
.pipe(livereload());
});
/*
SASS
*/
gulp.task("sass", function () {
return gulp.src("frontend/scss/**/*.scss")
.pipe(sourcemaps.init())
.pipe(sass({"outputStyle" : "compressed", "errLogToConsole": true}))
.pipe(postcss([autoprefixer({browsers: ["last 2 versions"]})]))
.pipe(sourcemaps.write())
.pipe(rev())
.pipe(gulp.dest("public_html/assets/styles/"))
.pipe(rev.manifest({path: "public_html/assets/assets.json", merge : true}))
.pipe(gulp.dest(''))
.pipe(livereload());
});
/*
Clean up
*/
gulp.task("clean", function(callback){
del(["public_html/assets/**/*"], callback);
});