-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·68 lines (56 loc) · 1.96 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
const gulp = require('gulp');
const gulpFileInclude = require('gulp-file-include');
const replace = require('gulp-token-replace');
const sass = require('gulp-sass')(require('sass'));
const ts = require("gulp-typescript");
const sourcemaps = require('gulp-sourcemaps');
const paths = {
scripts: {
src: './dev',
dest: './dist'
}
};
const tsProject = ts.createProject("tsconfig.json");
const tokenReplaceConfig = require('./.tokenreplacerc.js');
gulp.task('bundleHTML', function() {
return gulp.src(`${paths.scripts.src}/**/*.html`)
.pipe(gulpFileInclude({
prefix: '#@',
basepath: '@file'
}))
.pipe(replace({global:tokenReplaceConfig}))
.pipe(gulp.dest(paths.scripts.dest));
});
gulp.task('bundleImages', function() {
return gulp.src(`${paths.scripts.src}/images/**/**/**/*`)
.pipe(gulp.dest(`${paths.scripts.dest}/images`));
});
gulp.task('bundlePublic', function() {
return gulp.src(`${paths.scripts.src}/public/**/**/**/*`)
.pipe(gulp.dest(`${paths.scripts.dest}`));
});
gulp.task('bundleSASS', function() {
return gulp.src(`${paths.scripts.src}/sass/**/**/**/*`)
.pipe(sourcemaps.init())
.pipe(sass.sync({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(sourcemaps.write())
.pipe(gulp.dest(`${paths.scripts.dest}/css`));
});
gulp.task('bundleFonts', function() {
return gulp.src(`${paths.scripts.src}/fonts/**/**/**/*`)
.pipe(gulp.dest(`${paths.scripts.dest}/fonts`));
});
gulp.task("bundleTS", function() {
return tsProject.src()
.pipe(sourcemaps.init())
.pipe(tsProject()).js
.pipe(sourcemaps.write())
.pipe(gulp.dest(`${paths.scripts.dest}/js`));
});
// gulp.task('bundleJS', function() {
// return gulp.src(`${paths.scripts.src}/js/**/**/**/*`)
// .pipe(gulp.dest(`${paths.scripts.dest}/js`));
// });
gulp.task('default', function() {
gulp.watch(paths.scripts.src, gulp.parallel('bundleHTML', 'bundlePublic', 'bundleTS', 'bundleSASS', 'bundleFonts', 'bundleImages'));
});