-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
101 lines (85 loc) · 2.68 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
const gulp = require('gulp');
const npath = require('path');
const sassCompiler = require('sass');
const sass = require('gulp-sass')(sassCompiler);
const ts = require('gulp-typescript');
const babel = require('gulp-babel');
const clean = require('gulp-clean');
// const info = require('fha-gulp-info');
// const fs = require('fs');
const srcDir = './';
const destDir = './public/';
const tsProject = ts.createProject('./src/tsconfig.json');
/* -------------------------------------------------------------------- CLEAN */
gulp.task('clean', () => gulp.src(
[ npath.resolve(destDir), './src/js' ],
{
read: false,
allowEmpty: true,
},
).pipe(clean()));
/* --------------------------------------------------------------------- INFO */
// gulp.task('build-info', (cb) => {
// info.generate().then((item) => {
// fs.writeFileSync('build-info.json', JSON.stringify(item), { encoding: 'UTF-8' });
// cb();
// });
// });
/* ------------------------------------------------------------------- ASSETS */
gulp.task('sass', () => gulp
.src([
npath.resolve(srcDir, 'src/stylesheets/**/*.scss'),
'node_modules/font-awesome/scss/*.scss',
])
.pipe(sass({
errLogToConsole: true,
outputStyle: 'compressed',
indentedSyntax: false,
includePaths: [
'node_modules/bootstrap/scss/*.scss',
],
}).on('error', sass.logError))
.pipe(gulp.dest('./public/stylesheets')));
gulp.task('babel', () => gulp
.src([ npath.resolve(srcDir, 'src/javascript/**/*.js') ])
.pipe(babel({
presets: [ '@babel/env' ],
}))
.pipe(gulp.dest('./public/javascript')));
gulp.task('typescript', () => gulp
.src([ npath.resolve(srcDir, 'src/ts/**/*.ts') ])
.pipe(tsProject())
.js
.pipe(gulp.dest('./src/js')));
// Copies javascript files to public folder
gulp.task('copy-scripts', () => gulp
.src([
'./node_modules/bootstrap/dist/js/*.js',
'./node_modules/jquery/dist/jquery.*.js',
'./node_modules/popper.js/dist/*.js',
// './src/js/**/*.js',
])
.pipe(gulp.dest('./public/javascript')));
// Copies images to public folder
gulp.task('copy-images', () => gulp
.src([
'./src/images/**/*.{png,ico,gif,jpg,svg}',
'./node_modules/bootstrap-icons/*.svg',
])
.pipe(gulp.dest('./public/images')));
// Copies fonts to public folder
gulp.task('copy-fonts', () => gulp
.src([
'./src/fonts/*.{woff,woff2}',
])
.pipe(gulp.dest('./public/fonts')));
/* -------------------------------------------------------------------- Tasks */
gulp.task(
'build',
gulp.series(
'clean',
gulp.parallel('sass', 'babel', 'typescript'),
gulp.parallel('copy-scripts', 'copy-images', 'copy-fonts'),
),
);
gulp.task('default', gulp.series('build'));