-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: use page builder plugin and move to esbuild (#21)
- Loading branch information
Showing
16 changed files
with
3,301 additions
and
1,804 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import * as esbuild from 'esbuild'; | ||
|
||
import autoprefixer from 'gulp-autoprefixer'; | ||
import {exec} from 'child_process'; | ||
import gulp from 'gulp'; | ||
import sass from 'gulp-dart-sass'; | ||
|
||
const ENTRIES = { | ||
js: { | ||
tsc_out: ['./dist/js/main.js'], | ||
out: './dist/js/main.min.js', | ||
watch: ['./src/ts/**/*.ts'], | ||
}, | ||
sass: { | ||
src: ['./src/sass/**/*.sass'], | ||
out: './dist/css/', | ||
watch: ['./src/sass/**/*.sass'], | ||
}, | ||
}; | ||
|
||
/** | ||
* esBuild does not do type checks and can build with type errors so we first run | ||
* `tsc` and generate a JS file. esBuild is then run on the outputted JS file. | ||
* | ||
* The entry point of tsc compilation is configured in tsconfig `include`. | ||
*/ | ||
const runEsBuild = async prod => { | ||
return new Promise<void>((resolve, reject) => { | ||
exec('tsc', async (error, stderr) => { | ||
if (stderr) { | ||
console.error('Typescript errors'); | ||
console.error(stderr); | ||
reject(); | ||
} else { | ||
await esbuild.build({ | ||
entryPoints: ENTRIES.js.tsc_out, | ||
outfile: ENTRIES.js.out, | ||
bundle: true, | ||
platform: 'browser', | ||
minify: prod, | ||
}); | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
}; | ||
|
||
gulp.task('build:js', async () => { | ||
await runEsBuild(true); | ||
}); | ||
|
||
gulp.task('build:sass', () => { | ||
return gulp | ||
.src(ENTRIES.sass.src) | ||
.pipe( | ||
sass({ | ||
outputStyle: 'compressed', | ||
includePaths: ['./node_modules/'], | ||
}) | ||
) | ||
.on('error', sass.logError) | ||
.pipe(autoprefixer()) | ||
.pipe(gulp.dest(ENTRIES.sass.out)); | ||
}); | ||
|
||
gulp.task('watch:sass', () => { | ||
return gulp.watch( | ||
ENTRIES.sass.watch, | ||
{ignoreInitial: false}, | ||
gulp.series('build:sass') | ||
); | ||
}); | ||
|
||
gulp.task('watch:js', async cb => { | ||
await runEsBuild(false); | ||
gulp.watch(ENTRIES.js.watch, async () => { | ||
await runEsBuild(false); | ||
cb(); | ||
}); | ||
}); | ||
|
||
gulp.task('watch', gulp.parallel('watch:js', 'watch:sass')); | ||
gulp.task('build', gulp.parallel('build:sass', 'build:js')); | ||
gulp.task('default', gulp.series('watch')); |
Oops, something went wrong.