forked from convergencelabs/ace-collab-ext
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
90 lines (77 loc) · 2.13 KB
/
gulpfile.babel.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
81
82
83
84
85
86
87
88
89
90
import {src, dest, series} from "gulp";
import insert from "gulp-insert";
import webpackStream from "webpack-stream";
import webpack from "webpack";
import rename from "gulp-rename";
import uglify from "gulp-uglify-es";
import sourcemaps from "gulp-sourcemaps";
import del from "del";
import cleanCSS from "gulp-clean-css";
import header from "gulp-header";
import fs from "fs";
import gulpTypescript from "gulp-typescript";
import typescript from "typescript";
const tsProject = gulpTypescript.createProject("tsconfig.json", {
declaration: true,
typescript: typescript
});
const copyFiles = () =>
src(["README.md", "LICENSE.txt", "package.json"])
.pipe(dest("dist"));
const umd = () => {
const outputPath = "dist/umd";
const packageJson = JSON.parse(fs.readFileSync("./package.json"));
const headerTxt = fs.readFileSync("./copyright-header.txt");
return src("./src/ts/index.ts")
.pipe(webpackStream(require("./webpack.config.js"), webpack))
.pipe(header(headerTxt, {package: packageJson}))
.pipe(dest(outputPath));
};
const minifyUmd = () =>
src("dist/umd/ace-collab-ext.js")
.pipe(sourcemaps.init())
.pipe(uglify({
output: {
comments: "some"
}
}))
.pipe(rename({extname: ".min.js"}))
.pipe(sourcemaps.write("."))
.pipe(dest("dist/umd"));
const commonjs = () =>
src("src/ts/*.ts")
.pipe(tsProject())
.js
.pipe(dest("dist/lib"));
const typings = () =>
src("src/ts/*.ts")
.pipe(tsProject())
.dts.pipe(dest("dist/typings"));
const appendTypingsNamespace = () =>
src("dist/typings/index.d.ts", {base: './'})
.pipe(insert.append('\nexport as namespace AceCollabExt;\n'))
.pipe(dest("./"));
const css = () =>
src("src/css/*.css")
.pipe(dest("dist/css"));
const minifyCss = () =>
src(`dist/css/ace-collab-ext.css`)
.pipe(sourcemaps.init())
.pipe(cleanCSS())
.pipe(rename({extname: ".min.css"}))
.pipe(sourcemaps.write("."))
.pipe(dest("dist/css"));
const clean = () => del(["dist"]);
const dist = series([
umd,
minifyUmd,
commonjs,
typings,
appendTypingsNamespace,
css,
minifyCss,
copyFiles]);
export {
dist,
clean
}