-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
82 lines (75 loc) · 2.13 KB
/
gulpfile.js
File metadata and controls
82 lines (75 loc) · 2.13 KB
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
'use strict';
var gulp = require('gulp'),
rigger = require('gulp-rigger'),
watch = require('gulp-watch'),
notifier = require('node-notifier'),
sourcemaps = require('gulp-sourcemaps'),
uglify = require('gulp-uglify'),
cleancss = require('gulp-clean-css'),
sass = require('gulp-sass');
var path = {
src: {
js: {
main: 'Scripts/main.js',
vendor: 'Scripts/vendor.js'
},
css: {
main: 'Styles/main.scss',
vendor: 'Styles/vendor.scss'
}
},
build: {
basePath: 'wwwroot',
js: 'js',
css: 'css'
},
watch: {
css: 'Styles/**/*',
js: 'Scripts/**/*'
}
};
function swallowError(error) {
//If you want details of the error in the console
console.log(error.toString());
notifier.notify({
'title': 'Gulp Error',
'message': error.message
});
this.emit('end');
}
gulp.task('js:build', function () {
gulp.src(path.src.js.main)
.pipe(rigger())
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(sourcemaps.write())
.on('error', swallowError)
.pipe(gulp.dest(path.build.basePath + '/' + path.build.js));
gulp.src(path.src.js.vendor)
.pipe(rigger())
.on('error', swallowError)
.pipe(gulp.dest(path.build.basePath + '/' + path.build.js));
});
gulp.task('css:build', function () {
gulp.src(path.src.css.main)
.pipe(sass())
.pipe(sourcemaps.init())
.pipe(cleancss({rebase: false}))
.pipe(sourcemaps.write())
.on('error', swallowError)
.pipe(gulp.dest(path.build.basePath + '/' + path.build.css));
gulp.src(path.src.css.vendor)
.pipe(sass())
.pipe(cleancss({rebase: false}))
.on('error', swallowError)
.pipe(gulp.dest(path.build.basePath + '/' + path.build.css));
});
gulp.task('watch', function() {
watch(path.watch.js, function(event, cb) {
gulp.start('js:build');
});
watch(path.watch.css, function(event, cb) {
gulp.start('css:build');
});
});
gulp.task('default', ['js:build', 'css:build']);