-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
113 lines (98 loc) · 2.77 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
var gulp = require('gulp');
var sass = require('gulp-sass');
var sassGlob = require('gulp-sass-glob');
var merge = require('merge-stream');
var rename = require("gulp-rename");
var autoprefixer = require('gulp-autoprefixer');
var uglifycss = require('gulp-uglifycss');
var uglify = require('gulp-uglify');
var ts = require('gulp-typescript');
var tsProject = ts.createProject("tsconfig.json");
var runSequence = require('run-sequence');
var appPath = 'app/assets/';
var srcPath = 'src/';
var distPath = 'dist/';
gulp.task('sass', function() {
var app = gulp.src(appPath + 'stylesheets/app.scss')
.pipe(sassGlob())
.pipe(sass({
indentedSyntax: true,
outputStyle: 'expanded'
}).on('error', sass.logError))
.pipe(gulp.dest(appPath + 'stylesheets/'));
var modal = gulp.src([
srcPath + 'scss/multi-modal-classic.scss',
srcPath + 'scss/multi-modal-modern.scss'
])
.pipe(sassGlob())
.pipe(sass({
indentedSyntax: true,
outputStyle: 'expanded'
}).on('error', sass.logError))
.pipe(gulp.dest(distPath));
return merge(app, modal);
});
gulp.task('autoprefixer', function() {
var app = gulp.src(appPath + 'stylesheets/app.css')
.pipe(autoprefixer({
browsers: '> 1%'
}))
.pipe(gulp.dest(appPath + 'stylesheets/'));
var modal = gulp.src([
distPath + 'multi-modal-classic.css',
distPath + 'multi-modal-modern.css'
])
.pipe(autoprefixer({
browsers: '> 1%'
}))
.pipe(gulp.dest(distPath));
return merge(app, modal);
});
gulp.task('uglify-css', function() {
return gulp.src([
distPath + 'multi-modal-classic.css',
distPath + 'multi-modal-modern.css'
])
.pipe(uglifycss())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest(distPath));
});
gulp.task('copy-ts', function() {
return gulp.src(srcPath + 'typescript/multi-modal.ts')
.pipe(gulp.dest(distPath));
});
gulp.task('typescript', function() {
return tsProject.src()
.pipe(ts(tsProject))
.js.pipe(gulp.dest(distPath));
});
gulp.task('uglify-js', function() {
gulp.src(distPath + 'multi-modal.js')
.pipe(uglify())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest(distPath));
});
gulp.task('watch', function() {
gulp.watch([
appPath + 'stylesheets/**/*.scss',
srcPath + 'scss/*.scss'
], ['sass']);
gulp.watch([
appPath + 'stylesheets/*.css',
distPath + '*.css'
], runSequence('autoprefixer'));
gulp.watch([
srcPath + 'typescript/*.ts'
], ['typescript']);
});
gulp.task('compile', function() {
runSequence('sass', 'autoprefixer', 'uglify-css');
runSequence('copy-ts', 'typescript', 'uglify-js');
});
gulp.task('default', ['watch'], function() {
gulp.start('compile');
});