-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
38 lines (33 loc) · 981 Bytes
/
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
'use strict'
const path = require('path')
const gulp = require('gulp')
const del = require('del')
const concat = require('gulp-concat')
const rename = require('gulp-rename')
const wrap = require('gulp-wrap')
const replace = require('gulp-replace')
const PATH = {
src: './src/',
dest: './dist/',
}
const FILENAME = 'history.state'
const NS = 'historyState'
gulp.task('default', ['clean'], function () {
gulp.start('js')
})
gulp.task('clean', function (callback) {
del(path.join(PATH.dest, '*.*'), callback)
})
gulp.task('js', function() {
gulp.src([
path.join(PATH.src, FILENAME + '.js'),
path.join(PATH.src, '_wrapper/auto-polyfill.js'),
])
.pipe(concat('temp.js', {newLine: ';'}))
.pipe(wrap({src: path.join(PATH.src, '_wrapper/umd.ejs')}))
.pipe(replace(/\{sample}/g, NS))
.pipe(replace(/\/\*\* DEBUG_INFO_START \*\*\//g, '/*'))
.pipe(replace(/\/\*\* DEBUG_INFO_END \*\*\//g, '*/'))
.pipe(rename(FILENAME + '.umd.js'))
.pipe(gulp.dest(PATH.dest))
})