forked from OutSystems/outsystems-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
59 lines (48 loc) · 1.76 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 fs = require('fs');
const browser = require('browser-sync');
const clean = require('gulp-clean');
// Get dependencies tasks
const createScssFile = require('./gulp/Tasks/CreateScssFile');
const cssTranspile = require('./gulp/Tasks/ScssTanspile');
const tsTranspile = require('./gulp/Tasks/TsTanspile');
const updatetVersion = require('./gulp/Tasks/UpdateVersion');
// 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() {
// Get the index.html base file
let code = fs.readFileSync('./gulp/Template/index.html', 'utf8');
// Create the new index.html at the dist folder!
fs.writeFileSync(`${distFolder}/index.html`, code, 'utf8');
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,
createScssFile.update_osui_scss_file_dev,
parallel(cssTranspile.transpileDev, tsTranspile.transpileDev),
parallel(watchFiles, initServer)
);
exports.createProduction = series(
cleanOldFiles,
createScssFile.update_osui_scss_file_prod,
cssTranspile.transpileProd,
tsTranspile.transpileProd
);
exports.updateScssFile = createScssFile.update_osui_scss_file_dev;
exports.updateVersion = updatetVersion.setVersion;
exports.gtaSetVersion = updatetVersion.gtaSetVersion;