-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
gulpfile.js
122 lines (106 loc) · 3.33 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// generated on 2018-02-14 using generator-webapp 3.0.1
const gulp = require('gulp');
const gulpLoadPlugins = require('gulp-load-plugins');
const browserSync = require('browser-sync').create();
const del = require('del');
const runSequence = require('run-sequence');
var minify = require('gulp-minify');
var rename = require('gulp-rename');
const $ = gulpLoadPlugins();
const reload = browserSync.reload;
let dev = true;
gulp.task('styles', () => {
return gulp.src('app/styles/*.scss')
.pipe($.plumber())
.pipe($.if(dev, $.sourcemaps.init()))
.pipe($.sass.sync({
outputStyle: 'expanded',
precision: 10,
includePaths: ['.']
}).on('error', $.sass.logError))
.pipe($.autoprefixer({browsers: ['> 1%', 'last 2 versions', 'Firefox ESR']}))
.pipe($.if(dev, $.sourcemaps.write()))
.pipe(gulp.dest('app/css'))
.pipe(reload({stream: true}));
});
gulp.task('styles-dist', () => {
return gulp.src('app/styles/*.scss')
.pipe($.plumber())
.pipe($.sass.sync({
outputStyle: 'expanded',
precision: 10,
includePaths: ['.']
}).on('error', $.sass.logError))
.pipe($.autoprefixer({browsers: ['> 1%', 'last 2 versions', 'Firefox ESR']}))
.pipe(gulp.dest('dist/css'))
.pipe(reload({stream: true}));
});
gulp.task('styles-dist_min', () => {
return gulp.src('app/styles/*.scss')
.pipe($.plumber())
.pipe($.sass.sync({
outputStyle: 'compressed',
precision: 10,
includePaths: ['.']
}).on('error', $.sass.logError))
.pipe($.autoprefixer({browsers: ['> 1%', 'last 2 versions', 'Firefox ESR']}))
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('dist/css'))
.pipe(reload({stream: true}));
});
gulp.task('compress', function() {
gulp.src('app/scripts/*.js')
.pipe(minify({
ext:{
src:'.js',
min:'.min.js'
},
exclude: ['tasks'],
ignoreFiles: ['application.js']
}))
// .pipe(rename({
// suffix: '.min'
// }))
.pipe(gulp.dest('dist/scripts'))
});
gulp.task('images', () => {
return gulp.src('app/images/**/*')
.pipe($.cache($.imagemin()))
.pipe(gulp.dest('dist/images'));
});
gulp.task('fonts', () => {
return gulp.src(require('main-bower-files')('**/*.{eot,svg,ttf,woff,woff2}', function (err) {})
.concat('app/fonts/**/*'))
.pipe($.if(dev, gulp.dest('.tmp/fonts'), gulp.dest('dist/fonts')));
});
gulp.task('clean', del.bind(null, ['.tmp', 'dist']));
gulp.task('serve', () => {
//runSequence(['clean', 'wiredep'], ['styles', 'scripts', 'fonts'], () => {
runSequence(['styles'], () => {
browserSync.init({
notify: false,
port: 9000,
server: {
baseDir: ['.tmp', 'app'],
routes: {
'/bower_components': 'bower_components'
}
}
});
gulp.watch([
'app/*.html',
'app/images/**/*',
'.tmp/fonts/**/*'
]).on('change', reload);
gulp.watch('app/styles/**/*.scss', ['styles']);
//gulp.watch('app/scripts/**/*.js', ['scripts']);
//gulp.watch('app/fonts/**/*', ['fonts']);
//gulp.watch('bower.json', ['wiredep', 'fonts']);
});
});
// gulp.task('build', ['lint', 'html', 'images', 'fonts', 'extras'], () => {
// return gulp.src('dist/**/*').pipe($.size({title: 'build', gzip: true}));
// });
gulp.task('default', ['styles-dist', 'styles-dist_min', 'compress'], () => {});