-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
61 lines (51 loc) · 1.61 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
const SASS_AUTOPREFIXER_OPTIONS = {
browsers: [
'last 2 versions',
'not ie <= 10',
'not ie_mob <= 10',
],
cascade: false,
};
const HTML_MINIFIER_OPTIONS = {
collapseWhitespace: true,
removeComments: true,
caseSensitive: true,
removeAttributeQuotes: false
};
const gulp = require('gulp');
const inlineResources = require('./scripts/gulp/inline-resources');
const sass = require('gulp-sass');
const gulpSass = require('gulp-sass');
const gulpSourcemaps = require('gulp-sourcemaps');
const gulpAutoprefixer = require('gulp-autoprefixer');
const gulpMinifyCss = require('gulp-clean-css');
const gulpMinifyHtml = require('gulp-htmlmin');
const rename = require('gulp-rename');
gulp.task('copy-and-inline-resource', copyHtml);
function copyHtml() {
gulp.src('src/lib/**/*.html')
.pipe(gulpMinifyHtml(HTML_MINIFIER_OPTIONS))
.pipe(gulp.dest('./dist/')).on('end', buildCss);
}
function buildCss() {
//noinspection JSUnresolvedFunction
gulp.src('./src/lib/**/*.scss').
pipe(gulpSourcemaps.init()).pipe(gulpSass().on('error', gulpSass.logError))
.pipe(gulpAutoprefixer(SASS_AUTOPREFIXER_OPTIONS))
.pipe(gulpSourcemaps.write('.'))
.pipe(gulpMinifyCss())
.pipe(gulp.dest('./dist/'))
.on('end', copyScss);
}
function copyScss () {
gulp.src('./src/lib/**/*.scss')
.pipe(gulp.dest('./dist/')).on('end', copyPackage);
}
function copyPackage () {
gulp.src('./package-dist.json').pipe(rename('package.json'))
.pipe(gulp.dest('./dist/')).on('end', inlineResource);
}
function inlineResource() {
inlineResources('./dist/');
}
gulp.task('default', ['copy-and-inline-resource']);