forked from jaredreich/pell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
55 lines (47 loc) · 1.32 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
const babel = require('rollup-plugin-babel')
const cssnano = require('gulp-cssnano')
const gulp = require('gulp')
const rename = require('gulp-rename')
const rollup = require('gulp-rollup')
const sass = require('gulp-sass')(require('sass'));
const size = require('gulp-size')
const rollupConfig = minimize => ({
input: './src/pell.js',
output: {
name: 'pell',
format: 'umd',
exports: 'named',
},
plugins: [babel({ exclude: 'node_modules/**' })].concat(
minimize
? []
: []
)
})
gulp.task('script', (done) => {
gulp.src('./src/*.js')
.pipe(rollup(rollupConfig(false)))
.pipe(size({ showFiles: true }))
.pipe(gulp.dest('./dist'))
gulp.src('./src/*.js')
.pipe(rollup(rollupConfig(true)))
.pipe(rename('pell.min.js'))
.pipe(size({ showFiles: true }))
.pipe(size({ gzip: true, showFiles: true }))
.pipe(gulp.dest('./dist'))
done()
})
gulp.task('style', (done) => {
gulp.src(['./src/pell.scss'])
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./dist'))
.pipe(cssnano())
.pipe(rename('pell.min.css'))
.pipe(gulp.dest('./dist'))
done()
})
gulp.task('watch', function (done) {
gulp.watch('./src/pell.scss', gulp.series('sass'));
gulp.watch('./src/pell.js', gulp.series('js'));
})
gulp.task('default', gulp.series('style', 'script'));