forked from sweetalert2/sweetalert2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
111 lines (94 loc) · 2.5 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
const gulp = require('gulp')
const cleanCSS = require('gulp-clean-css')
const sass = require('gulp-sass')
const rename = require('gulp-rename')
const autoprefix = require('gulp-autoprefixer')
const standard = require('gulp-standard')
const sassLint = require('gulp-sass-lint')
const ts = require('gulp-typescript')
const tslint = require('gulp-tslint')
const pack = require('./package.json')
const utils = require('./config/utils.js')
gulp.task('compress', ['js-lint', 'commonjs', 'dev', 'production', 'all', 'all.min'])
gulp.task('commonjs', () => {
return utils.packageRollup({
dest: 'dist/' + pack.name + '.common.js',
format: 'cjs'
})
})
gulp.task('dev', () => {
return utils.packageRollup({
dest: 'dist/' + pack.name + '.js',
format: 'umd'
})
})
gulp.task('production', () => {
return utils.packageRollup({
dest: 'dist/' + pack.name + '.min.js',
format: 'umd',
minify: true
})
})
gulp.task('all', ['sass'], () => {
return utils.packageRollup({
entry: 'src/sweetalert2.all.js',
dest: 'dist/' + pack.name + '.all.js',
format: 'umd'
})
})
gulp.task('all.min', ['sass'], () => {
return utils.packageRollup({
entry: 'src/sweetalert2.all.js',
dest: 'dist/' + pack.name + '.all.min.js',
format: 'umd',
minify: true
})
})
gulp.task('sass', ['sass-lint'], (cb) => {
gulp.src('src/sweetalert2.scss')
.pipe(sass())
.pipe(autoprefix())
.pipe(gulp.dest('dist'))
.pipe(cleanCSS())
.pipe(rename({extname: '.min.css'}))
.pipe(gulp.dest('dist'))
.on('end', cb)
gulp.src('assets/example.scss')
.pipe(sass())
.pipe(autoprefix())
.pipe(gulp.dest('assets'))
})
gulp.task('ts', ['ts-lint'], () => {
return gulp.src('sweetalert2.d.ts')
.pipe(ts())
})
gulp.task('lint', ['js-lint', 'sass-lint', 'ts-lint'])
gulp.task('js-lint', () => {
return gulp.src(['src/**/*.js', 'test/*.js'])
.pipe(standard())
.pipe(standard.reporter('default', {
breakOnError: true
}))
})
gulp.task('sass-lint', () => {
return gulp.src(['src/**/*.scss', 'assets/**/*.scss'])
.pipe(sassLint())
.pipe(sassLint.format())
.pipe(sassLint.failOnError())
})
gulp.task('ts-lint', () => {
return gulp.src('sweetalert2.d.ts')
.pipe(tslint({ formatter: 'verbose' }))
.pipe(tslint.report())
})
gulp.task('default', ['sass', 'ts', 'compress'])
gulp.task('watch', () => {
gulp.watch([
'src/**/*.js',
'test/*.js'
], ['compress'])
gulp.watch([
'src/*.scss',
'assets/example.scss'
], ['sass', 'compress'])
})