forked from sweetalert2/sweetalert2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
80 lines (67 loc) · 1.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
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 pack = require('./package.json')
const utils = require('./config/utils.js')
gulp.task('compress', ['js-lint', 'commonjs', 'dev', 'production'])
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('sass', ['sass-lint'], () => {
gulp.src('src/sweetalert2.scss')
.pipe(sass())
.pipe(autoprefix())
.pipe(gulp.dest('dist'))
.pipe(cleanCSS())
.pipe(rename({extname: '.min.css'}))
.pipe(gulp.dest('dist'))
gulp.src('assets/example.scss')
.pipe(sass())
.pipe(autoprefix())
.pipe(gulp.dest('assets'))
})
gulp.task('lint', ['js-lint', 'sass-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('default', ['compress', 'sass'])
gulp.task('watch', () => {
gulp.watch([
'src/**/*.js',
'test/*.js'
], ['compress'])
gulp.watch([
'src/sweetalert2.scss',
'assets/example.scss'
], ['sass'])
})