-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TGS-46: 2022 Improvements/Cleanup #47
Conversation
gulpfile.js
Outdated
reload = browserSync.reload, | ||
runTimestamp = Math.round(Date.now() / 1000); | ||
// @TODO – Replace gulp-stylelint with official version once it's released. | ||
const babel = require('gulp-babel'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thought here I was thinking maybe we should change out babel for swc instead
Comparison -> https://swc.rs/blog/perf-swc-vs-babel
Also we can still use babel-eslint but that could be changed soon see here -> swc-project/swc#246
Here is how to do it -> https://github.com/konclave/gulp-swc
Once installed we could add
// Add swc
const swc = require('gulp-swc');
// Add options to configure swc: https://swc.rs/docs/configuring-swc
const swcOptions = {
jsc: {
target: 'es5',
},
sourceMaps: true,
};
// Add .pipe(swc(swcOptions)) instead of .pipe(babel({ presets: ['@babel/env'], }))
gulp.task('scripts', () => {
return gulp
.src(paths.scripts.src)
.pipe(
plumber({
errorHandler: function(err) {
notify.onError({
title: 'Gulp error in ' + err.plugin,
message: err.toString(),
})(err);
beeper();
},
})
)
.pipe(swc(swcOptions))
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(concat('app.js'))
.pipe(terser())
.pipe(sourcemaps.write('./maps'))
.pipe(gulp.dest(paths.scripts.dist))
.pipe(reload({ stream: true }));
});
I already have this working locally so I can confirm its a drop in replacement for babel and super fast.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to work great! I'm not sure if we still need the babel stuff for https://github.com/thirdandgrove/tag-gulp-starter/pull/47/files#diff-25789e3ba4c2adf4a68996260eb693a441b4a834c38b76167a120f0b51b969f7R110. Should we try to replace this too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great !!
#46