Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 2958934

Browse files
committed
Additional build fixes
1 parent aa01541 commit 2958934

File tree

8 files changed

+1196
-2210
lines changed

8 files changed

+1196
-2210
lines changed

Diff for: gulp/browserify.js

-43
This file was deleted.

Diff for: gulp/build.js

+14-12
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ const partials = () => {
2222
}))
2323
.pipe($.angularTemplatecache('templateCacheHtml.js', {
2424
module: 'topcoderX',
25-
root: 'app',
25+
transformUrl: url => url.replace(/^\/+/, '')
2626
}))
2727
.pipe(gulp.dest(paths.tmp + '/partials/'))
2828
}
2929
gulp.task('partials', partials);
3030

31-
const htmlFn = () => {
31+
const html = () => {
3232
return new Promise(async (resolve, reject) => {
3333
const partialsInjectFile = gulp.src(paths.tmp + '/partials/templateCacheHtml.js', { read: false });
3434
const partialsInjectOptions = {
@@ -59,25 +59,28 @@ const htmlFn = () => {
5959
.on('error', reject);
6060
});
6161
}
62-
const html = gulp.series(inject, partials, htmlFn);
63-
gulp.task('html', html);
62+
const htmlTask = gulp.series(inject, partials, html);
63+
gulp.task('html', htmlTask);
6464

6565
const images = () => {
6666
return gulp.src(paths.src + '/assets/images/**/*')
6767
.pipe(gulp.dest(paths.dist + '/assets/images/'));
6868
}
6969
gulp.task('images', images);
7070

71-
const fonts = () => {
71+
const fonts = () => new Promise(async (resolve, reject) => {
72+
const filter = (await import('gulp-filter')).default;
7273
return gulp.src([
7374
"node_modules/bootstrap/dist/fonts/*.{eot,svg,ttf,woff,woff2}",
7475
"node_modules/footable/css/fonts/*.{eot,svg,ttf,woff,woff2}"
7576
])
76-
.pipe($.filter('**/*.{eot,svg,ttf,woff,woff2}'))
77+
.pipe(filter('**/*.{eot,svg,ttf,woff,woff2}'))
7778
.pipe($.flatten())
7879
.pipe(gulp.dest(paths.dist + '/fonts/'))
79-
.pipe(gulp.dest(paths.dist + '/styles/fonts/'));
80-
}
80+
.pipe(gulp.dest(paths.dist + '/styles/fonts/'))
81+
.on('finish', resolve)
82+
.on('error', reject);
83+
});
8184
gulp.task('fonts', fonts);
8285

8386
const fontAwesome = () => {
@@ -92,11 +95,10 @@ const misc = () => {
9295
}
9396
gulp.task('misc', misc);
9497

95-
const cleanFn = (done) => {
98+
const clean = (done) => {
9699
$.del([paths.dist + '/', paths.tmp + '/', paths.src + '/app/config.js'], done);
97100
}
98-
const clean = gulp.series(cleanFn);
99-
gulp.task('clean', cleanFn);
101+
gulp.task('clean', clean);
100102

101103
const lint = () => {
102104
// ESLint ignores files with "node_modules" paths.
@@ -117,7 +119,7 @@ const lint = () => {
117119
}
118120
gulp.task('lint', lint);
119121

120-
const build = gulp.series(lint, html, images, fonts, fontAwesome, misc);
122+
const build = gulp.series(lint, htmlTask, images, fonts, fontAwesome, misc);
121123
gulp.task('build', build);
122124

123125
module.exports = { clean, build };

Diff for: gulp/esbuild.js

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
const gulp = require('gulp');
2+
const { createGulpEsbuild } = require('gulp-esbuild')
3+
const colors = require('ansi-colors')
4+
const log = require('fancy-log')
5+
const fs = require('fs');
6+
const { styles } = require('./styles');
7+
8+
const gulpEsbuild = createGulpEsbuild({
9+
incremental: true,
10+
piping: true,
11+
})
12+
13+
const esbuild = () => {
14+
const cssFilePath = gulp.paths.tmp + '/serve/app/bundle.css';
15+
16+
// Delete file if exists
17+
if (fs.existsSync(cssFilePath)) {
18+
fs.unlinkSync(cssFilePath);
19+
}
20+
21+
return gulp.src('./src/front/src/index.js')
22+
.pipe(gulpEsbuild({
23+
outfile: 'bundle.js',
24+
bundle: true,
25+
minify: process.env.DISABLE_MINIFY !== 'true',
26+
sourcemap: true,
27+
target: 'es2015',
28+
legalComments: 'external',
29+
loader: {
30+
'.eot': 'file',
31+
'.woff': 'file',
32+
'.woff2': 'file',
33+
'.ttf': 'file',
34+
'.svg': 'file',
35+
'.css': 'file'
36+
}
37+
}))
38+
.on('error', function (e) {
39+
log.error("ESBuild Error", colors.red(e.message));
40+
})
41+
.pipe(gulp.dest(gulp.paths.tmp + '/serve/app'));
42+
};
43+
44+
const esbuildTask = gulp.series(styles, esbuild);
45+
gulp.task('esbuild', esbuildTask);
46+
47+
module.exports = { esbuild: esbuildTask }

Diff for: gulp/inject.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
const gulp = require('gulp');
2-
const { browserify } = require('./browserify');
2+
const { esbuild } = require('./esbuild');
33

44
const paths = gulp.paths;
55

66
const $ = require('gulp-load-plugins')();
77

8-
const injectFn = () => {
8+
const inject = () => {
99
const injectStyles = gulp.src([
1010
paths.tmp + '/serve/{app,components}/**/*.css',
1111
'!' + paths.tmp + '/serve/app/vendor.css'
@@ -28,7 +28,7 @@ const injectFn = () => {
2828
.pipe(gulp.dest(paths.tmp + '/serve'));
2929
}
3030

31-
const inject = gulp.series(browserify, injectFn);
32-
gulp.task('inject', inject);
31+
const injectTask = gulp.series(esbuild, inject);
32+
gulp.task('inject', injectTask);
3333

34-
module.exports = { inject }
34+
module.exports = { inject: injectTask }

Diff for: gulp/styles.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const paths = gulp.paths;
44

55
const $ = require('gulp-load-plugins')();
66

7-
const styles = () => {
7+
const styles = () => new Promise(async (resolve, reject) => {
88
var lessOptions = {
99
paths: [
1010
'node_modules',
@@ -30,7 +30,8 @@ const styles = () => {
3030
addRootSlash: false
3131
};
3232

33-
const indexFilter = $.filter('index.less', { restore: true });
33+
const filter = (await import('gulp-filter')).default;
34+
const indexFilter = filter('index.less', { restore: true });
3435

3536
return gulp.src([
3637
paths.src + '/app/index.less',
@@ -45,7 +46,9 @@ const styles = () => {
4546
console.error(err.toString());
4647
this.emit('end');
4748
})
48-
.pipe(gulp.dest(paths.tmp + '/serve/app/'));
49-
}
49+
.pipe(gulp.dest(paths.tmp + '/serve/app/'))
50+
.on('finish', resolve)
51+
.on('error', reject);
52+
});
5053

5154
module.exports = { styles }

Diff for: gulp/watch.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const watchBuildFn = () => {
2727
paths.src + '/{app,components}/**/*.js',
2828
paths.src + '/{app,components}/**/*.html',
2929
'package.json'
30-
], gulp.series(inject, watchBuildFn));
30+
], gulp.series(inject, build));
3131
}
3232
const watchBuild = gulp.series(inject, build, watchBuildFn)
3333
gulp.task('watch:build', watchBuild);

0 commit comments

Comments
 (0)