Skip to content

Commit 6988275

Browse files
committed
Replace terser with esbuild
1 parent 9fddeaa commit 6988275

File tree

3 files changed

+520
-162
lines changed

3 files changed

+520
-162
lines changed

gulpfile.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import postcss from 'gulp-postcss';
88
import postUrl from 'postcss-url';
99
import autoprefixer from 'autoprefixer';
1010
import csso from 'postcss-csso';
11-
import terser from 'gulp-terser';
11+
import { createGulpEsbuild } from 'gulp-esbuild';
12+
import browserslistToEsbuild from 'browserslist-to-esbuild';
1213
import sharp from 'gulp-sharp-responsive';
1314
import svgo from 'gulp-svgmin';
1415
import { stacksvg } from 'gulp-stacksvg';
@@ -26,7 +27,7 @@ let isDevelopment = true;
2627
export 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

5253
export 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

Comments
 (0)