forked from jaredreich/pell
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
61 lines (55 loc) · 1.53 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 babel = require('rollup-plugin-babel')
const cssnano = require('gulp-cssnano')
const del = require('del')
const gulp = require('gulp')
const rename = require('gulp-rename')
const Rollup = require('rollup')
const rollup = require('gulp-rollup')
const run = require('run-sequence')
const sass = require('gulp-sass')
const size = require('gulp-size')
const uglify = require('rollup-plugin-uglify')
gulp.task('clean', () => del(['./dist']))
const rollupConfig = minimize => ({
rollup: Rollup,
entry: './src/pell.js',
moduleName: 'pell',
format: 'umd',
exports: 'named',
plugins: [babel({ exclude: 'node_modules/**' })].concat(
minimize
? [
uglify({
compress: { warnings: false },
mangle: true,
sourceMap: false
})
]
: []
)
})
gulp.task('script', () => {
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'))
})
gulp.task('style', () => {
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'))
})
gulp.task('default', ['clean'], () => {
run('script', 'style')
gulp.watch('./src/pell.scss', ['style'])
gulp.watch('./src/pell.js', ['script'])
})