-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
87 lines (79 loc) · 1.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
var gulp = require('gulp');
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var sort = require('gulp-sort');
var uglify = require('gulp-uglify');
var minify = require('gulp-clean-css');
var sourcemaps = require('gulp-sourcemaps');
var rev = require('gulp-rev');
var paths = {
assets: {
base: './resources',
styles: './resources/styles',
scripts: './resources/scripts'
},
build: {
base: './resources/build',
styles: './resources/build/styles',
scripts: './resources/build/scripts'
}
};
gulp.task('scss', function () {
return gulp.src(paths.assets.styles + '/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest(paths.build.styles));
});
gulp.task('css', function () {
return gulp.src(paths.assets.styles + '/**/*.css')
.pipe(gulp.dest(paths.build.styles));
});
gulp.task('styles', ['scss', 'css'], function () {
return gulp.src(paths.build.styles + '/*.css')
.pipe(sort())
.pipe(concat('styles.css'))
.pipe(minify())
.pipe(rev())
.pipe(gulp.dest(paths.build.base))
.pipe(rev.manifest(paths.build.base + '/rev-manifest.json', {
merge: true,
base: paths.build.base
}))
.pipe(gulp.dest(paths.build.base));
});
gulp.task('js', function () {
return gulp.src(paths.assets.scripts + '/**/*.js')
.pipe(gulp.dest(paths.build.scripts));
});
gulp.task('scripts', ['js'], function () {
return gulp.src(paths.build.scripts + '/*.js')
.pipe(sourcemaps.init())
.pipe(sort())
.pipe(concat('scripts.js'))
.pipe(uglify())
.pipe(rev())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(paths.build.base))
.pipe(rev.manifest(paths.build.base + '/rev-manifest.json', {
merge: true,
base: paths.build.base
}))
.pipe(gulp.dest(paths.build.base));
});
gulp.task('watch',function () {
gulp.watch(paths.assets.styles + '/**/*.*', [
'scss',
'css',
'styles',
]);
gulp.watch(paths.assets.scripts + '/**/*.*', [
'js',
'scripts'
]);
});
gulp.task('default', [
'scss',
'css',
'styles',
'js',
'scripts'
]);