-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
51 lines (42 loc) · 1.27 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
import { createRequire } from "module";
const require = createRequire(import.meta.url);
const { series, src, dest, watch } = require('gulp');
const rollup = require('gulp-rollup');
const uglify = require('gulp-uglify-es').default;
const rename = require('gulp-rename');
const destFolder = './dist';
const destNpmFolder = `${destFolder}/npm-package`;
const srcInput = './src/**/*.js';
const entryPoint = './src/PageCacheManager.js';
const destfilename = 'PageCacheManager'
const destFile = `${destFolder}/${destfilename}.js`;
const packageJson = 'package.json';
const readme = 'README.md';
function buildJS() {
return src(srcInput)
.pipe(rollup({
input: entryPoint,
output: {
format: 'es',
sourcemap: true,
},
}))
.pipe(rename({ basename : destfilename }))
.pipe(dest(destFolder));
}
function minify() {
return src(destFile)
.pipe(dest(destFolder))
.pipe(uglify())
.pipe(rename({ extname: '.min.js' }))
.pipe(dest(destFolder));
}
function generateNpmPackage(){
return src([destFile, packageJson, readme])
.pipe(dest(destNpmFolder));
}
let build = series(buildJS, minify, generateNpmPackage);
export { build }
export default function(){
watch(['src/*.js', 'src/*/*.js'], { ignoreInitial: false }, build);
};