@@ -8,7 +8,8 @@ import postcss from 'gulp-postcss';
88import postUrl from 'postcss-url' ;
99import autoprefixer from 'autoprefixer' ;
1010import csso from 'postcss-csso' ;
11- import terser from 'gulp-terser' ;
11+ import { createGulpEsbuild } from 'gulp-esbuild' ;
12+ import browserslistToEsbuild from 'browserslist-to-esbuild' ;
1213import sharp from 'gulp-sharp-responsive' ;
1314import svgo from 'gulp-svgmin' ;
1415import { stacksvg } from 'gulp-stacksvg' ;
@@ -26,7 +27,7 @@ let isDevelopment = true;
2627export function processMarkup ( ) {
2728 return src ( `${ PATH_TO_SOURCE } **/*.html` )
2829 . pipe ( nunjucksCompile ( ) )
29- . pipe ( htmlmin ( { collapseWhitespace : ! isDevelopment } ) )
30+ . pipe ( htmlmin ( { collapseWhitespace : ! isDevelopment } ) )
3031 . pipe ( dest ( PATH_TO_DIST ) )
3132 . pipe ( server . stream ( ) ) ;
3233}
@@ -50,8 +51,18 @@ export function processStyles () {
5051}
5152
5253export function processScripts ( ) {
53- return src ( `${ PATH_TO_SOURCE } scripts/**/*.js` )
54- . pipe ( terser ( ) )
54+ const gulpEsbuild = createGulpEsbuild ( { incremental : isDevelopment } ) ;
55+
56+ return src ( `${ PATH_TO_SOURCE } scripts/*.js` )
57+ . pipe ( gulpEsbuild ( {
58+ bundle : true ,
59+ format : 'esm' ,
60+ // splitting: true,
61+ platform : 'browser' ,
62+ minify : ! isDevelopment ,
63+ sourcemap : isDevelopment ,
64+ target : browserslistToEsbuild ( ) ,
65+ } ) )
5566 . pipe ( dest ( `${ PATH_TO_DIST } scripts` ) )
5667 . pipe ( server . stream ( ) ) ;
5768}
0 commit comments