-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathgulpfile.js
155 lines (142 loc) · 3.48 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
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
const gulp = require("gulp"),
uglify = require("gulp-uglify"),
cleanCss = require("gulp-clean-css"),
ts = require("gulp-typescript"),
rename = require("gulp-rename"),
sass = require("gulp-sass"),
browserSync = require("browser-sync"),
reload = browserSync.reload;
const srcTypescriptFolder = "./src/tsc",
srcTypescriptConfig = srcTypescriptFolder + "/tsconfig.json",
srcTypescriptConfigES6 = srcTypescriptFolder + "/tsconfig.es6.json",
srcTypescript = srcTypescriptFolder + "/**/*.ts",
srcJsFolder = "./src/js",
srcJsLocales = srcJsFolder + "/locales/*.js",
srcSassFolder = "./src/scss",
srcSass = srcSassFolder + "/**/*.scss",
srcSassMain = srcSassFolder + "/main.scss",
distFolder = "./dist",
distLocalesFolder = distFolder + "/locales",
demoFolder = "./demo",
demoJs = demoFolder + "/js",
demoJsLocales = demoJs + "/locales",
demoCss = demoFolder + "/css",
taskBrowserSync = "browserSync",
taskCompileTypescript = "ts",
taskCompileTypescriptES6 = "ts_es6",
taskCopyLocales = "copy_locales",
taskCompileSass = "sass",
taskWatcher = "watch";
// Browser-sync task
gulp.task(taskBrowserSync, done => {
browserSync({
server: {
baseDir: demoFolder
},
https: true,
port: 3000
});
browserSync.watch(demoFolder).on("change", browserSync.reload);
done();
});
// Typescript task
gulp.task(taskCompileTypescript, done => {
const tsProject = ts.createProject(srcTypescriptConfig);
const tsResult = gulp.src(srcTypescript).pipe(tsProject());
done();
return [
tsResult.js
.pipe(gulp.dest(demoJs))
.pipe(gulp.dest(distFolder))
.pipe(
uglify({
preserveComments: "false"
})
)
.pipe(
rename({
suffix: ".min"
})
)
.pipe(gulp.dest(distFolder))
.pipe(
reload({
stream: true
})
)
];
});
// Typescript ES6 compilation task
gulp.task(taskCompileTypescriptES6, done => {
const tsProject = ts.createProject(srcTypescriptConfigES6);
const tsResult = gulp.src(srcTypescript).pipe(tsProject());
done();
return [
tsResult.js.pipe(gulp.dest(distFolder)).pipe(
reload({
stream: true
})
)
];
});
// Copy locales task
gulp.task(taskCopyLocales, done => {
done();
return gulp
.src(srcJsLocales)
.pipe(gulp.dest(demoJsLocales))
.pipe(gulp.dest(distLocalesFolder));
});
// Sass task
gulp.task(taskCompileSass, done => {
done();
return gulp
.src(srcSassMain)
.pipe(sass())
.pipe(rename("jquery.brickyeditor.css"))
.pipe(gulp.dest(demoCss))
.pipe(gulp.dest(distFolder))
.pipe(cleanCss())
.pipe(
rename({
suffix: ".min"
})
)
.pipe(gulp.dest(distFolder))
.pipe(
reload({
stream: true
})
);
});
// Changes tracking task
gulp.task(taskWatcher, () => {
gulp.watch(srcTypescript, gulp.series(taskCompileTypescript));
gulp.watch(srcSass, gulp.series(taskCompileSass));
});
gulp.task(
"default",
gulp.series([
taskCompileTypescript,
taskCompileTypescriptES6,
taskCopyLocales,
taskCompileSass,
taskBrowserSync,
taskWatcher
]),
done => {
done();
}
);
gulp.task(
"build",
gulp.series([
taskCompileTypescript,
taskCompileTypescriptES6,
taskCopyLocales,
taskCompileSass
]),
done => {
done();
}
);