forked from sweetalert2/sweetalert2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
131 lines (110 loc) · 3.19 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
121
122
123
124
125
126
127
128
129
130
131
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 browserSync = require('browser-sync').create()
const pack = require('./package.json')
const utils = require('./utils/package-rollup') // TODO: Once this file stabilizes, make this line `const packageRollup = require('./utils/package-rollup')`
const execute = require('./utils/execute')
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', ['js-lint'], () => {
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'], () => {
return gulp.src('src/sweetalert2.scss')
.pipe(sass())
.pipe(autoprefix())
.pipe(gulp.dest('dist'))
})
gulp.task('css.min', ['sass'], () => {
return gulp.src('dist/sweetalert2.css')
.pipe(cleanCSS())
.pipe(rename({extname: '.min.css'}))
.pipe(gulp.dest('dist'))
})
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'])
.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('build', ['sass', 'ts', 'compress', 'css.min'])
gulp.task('default', ['build'])
gulp.task('watch', ['build'], () => {
gulp.watch(['src/**/*.js'], ['dev'])
gulp.watch(['src/*.scss'], ['sass'])
gulp.watch(['sweetalert2.d.ts'], ['ts'])
})
gulp.task('develop', ['develop:sandbox', 'develop:tests'])
gulp.task('develop:sandbox', ['watch'], () => {
browserSync.init({
port: 8080,
uiPort: 8081,
notify: false,
reloadOnRestart: true,
https: false,
server: ['./'],
startPath: 'test/sandbox.html'
})
gulp.watch([
'test/sandbox.html',
'dist/sweetalert2.js',
'dist/sweetalert2.css'
]).on('change', browserSync.reload)
})
gulp.task('develop:tests', ['watch'], async () => {
await execute(`karma start karma.conf.js`)
})