-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
92 lines (82 loc) · 2.19 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
let gulp = require('gulp'),
plugins = require('gulp-load-plugins')();
let src = {
scripts: ['app/**/*.js'],
styles: ['app/assets/css/**/*.scss'],
templates: ['app/**/*.html']
};
let dir = {
app: './app',
bootstrap: './node_modules/bootstrap-sass/assets/stylesheets',
scripts: './public/javascripts',
stylesheets: './public/stylesheets'
};
// Template cache
gulp.task('template-cache', function () {
return gulp.src(src.templates)
.pipe(plugins.angularTemplatecache(
'app.templates.js', {
module: 'app.templates',
standalone: true
}))
.pipe(gulp.dest(dir.app));
});
// JS Lint
gulp.task('js-lint', function () {
return gulp.src(src.scripts)
.pipe(plugins.jshint())
.pipe(plugins.jshint.reporter('jshint-stylish'));
});
// SASS Lint
gulp.task('sass-lint', function () {
return gulp.src(src.styles)
.pipe(plugins.sassLint())
.pipe(plugins.sassLint.format());
});
// Scripts
gulp.task('scripts', function () {
return gulp.src(src.scripts)
.pipe(plugins.concat('app.js'))
.pipe(plugins.babel())
.pipe(gulp.dest(dir.scripts))
.pipe(plugins.rename('app.min.js'))
.pipe(plugins.uglify())
.pipe(gulp.dest(dir.scripts));
});
// Styles
gulp.task('styles', function () {
return gulp.src(src.styles)
.pipe(plugins.sass({
includePaths: require('node-bourbon').with(dir.bootstrap),
importer: require('node-sass-import-once')
}).on('error', plugins.notify.onError(function (error) {
return "Error: " + error.message;
})))
.pipe(gulp.dest(dir.stylesheets))
.pipe(plugins.rename('styles.min.css'))
.pipe(plugins.cleanCss())
.pipe(gulp.dest(dir.stylesheets));
});
// Watch
gulp.task('watch', function () {
gulp.watch(src.scripts, [
'js-lint',
'scripts'
]);
gulp.watch(src.styles, [
'sass-lint',
'styles'
]);
gulp.watch(src.templates, [
'template-cache'
]);
});
// Default
gulp.task('default', [
'template-cache',
'js-lint',
'scripts',
'sass-lint',
'styles',
'watch'
]);