-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
103 lines (92 loc) · 2.96 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/**
* Gulpfile
*
* Rename and Minify JavaScript... and more (later).
*
* Install Command:
* npm install gulp gulp-rename gulp-uglify
*/
var gulp = require('gulp');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var requirejsOptimize = require('gulp-requirejs-optimize');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var autoprefixer = require('gulp-autoprefixer');
gulp.task('js', function () {
gulp.src('assets/js/builder/main.js')
.pipe(sourcemaps.init())
.pipe(requirejsOptimize(function(file) {
return {
name: '../lib/almond',
optimize: 'uglify2',
wrap: true,
baseUrl: 'assets/js/builder/',
include: ['main'],
preserveLicenseComments: false
};
}))
.pipe(rename('builder.js'))
.pipe(sourcemaps.write('/'))
.pipe(gulp.dest('assets/js/min/'));
gulp.src('assets/js/front-end/main.js')
.pipe(sourcemaps.init())
.pipe(requirejsOptimize(function(file) {
return {
name: '../lib/almond',
optimize: 'uglify2',
wrap: true,
baseUrl: 'assets/js/front-end/',
include: ['main'],
preserveLicenseComments: false
};
}))
.pipe(rename('front-end.js'))
.pipe(sourcemaps.write('/'))
.pipe(gulp.dest('assets/js/min/'));
});
gulp.task('sass', function () {
gulp.src('assets/scss/admin/builder.scss')
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer())
.pipe(sourcemaps.write('/'))
.pipe(gulp.dest('assets/css'));
gulp.src('assets/scss/front-end/display-structure.scss')
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer())
.pipe(sourcemaps.write('/'))
.pipe(gulp.dest('assets/css'));
gulp.src('assets/scss/front-end/display-opinions.scss')
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer())
.pipe(sourcemaps.write('/'))
.pipe(gulp.dest('assets/css'));
gulp.src('assets/scss/front-end/display-opinions-light.scss')
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer())
.pipe(sourcemaps.write('/'))
.pipe(gulp.dest('assets/css'));
gulp.src('assets/scss/front-end/display-opinions-dark.scss')
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer())
.pipe(sourcemaps.write('/'))
.pipe(gulp.dest('assets/css'));
});
// Watch Files For Changes
gulp.task('watch', function() {
gulp.watch('assets/js/builder/**/*.js', ['js']);
gulp.watch('assets/js/front-end/**/*.js', ['js']);
gulp.watch('assets/scss/**/*.scss', ['sass']);
});
// Default Task
gulp.task('default', ['js', 'sass', 'watch']);
function swallowError (error) {
//If you want details of the error in the console
console.log(error.toString());
this.emit('end');
}