-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
59 lines (45 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
const gulp = require('gulp');
const { watch, series, parallel } = require('gulp');
const browser = require('browser-sync');
const clean = require('gulp-clean');
const template = require('gulp-template');
// Get dependencies tasks
const cssTranspile = require('./gulp/tasks/ScssTanspile');
const createScssFile = require('./gulp/tasks/CreateScssFile');
const pattern = require('./gulp/tasks/NewPattern');
const tsTranspile = require('./gulp/tasks/TsTanspile');
// Local configs
const serverPort = 3000;
const distFolder = './dist';
const watchScssFiles = 'src/**/*.scss';
const watchTsFiles = 'src/**/*.ts';
// Clean Dist Folder
function cleanOldFiles() {
return gulp.src(distFolder + "/*", { read: false }).pipe(clean());
}
// Starts a Browser instance
function initServer() {
// Create index.html
gulp.src("./gulp/templates/index.html")
.pipe(template({}))
.pipe(gulp.dest(distFolder));
browser.init({ server: distFolder, port: serverPort, cors: true });
}
// Watch files changed
function watchFiles() {
watch(watchScssFiles, series(cssTranspile.transpileDev));
watch(watchTsFiles, series(tsTranspile.transpileDev));
};
// Gulp tasks
exports.startDevelopment = series(
cleanOldFiles,
parallel(cssTranspile.transpileDev, tsTranspile.transpileDev),
parallel(watchFiles, initServer)
);
exports.createProduction = series(
cleanOldFiles,
cssTranspile.transpileProd,
tsTranspile.transpileProd
);
exports.newPattern = pattern.create;
exports.updateScssFile = createScssFile.create_osui_scss_file;