Skip to content
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

Merged
merged 17 commits into from
Jan 27, 2022
Merged

TGS-46: 2022 Improvements/Cleanup #47

merged 17 commits into from
Jan 27, 2022

Conversation

jds-tag
Copy link
Contributor

@jds-tag jds-tag commented Jan 26, 2022

#46

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');
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

@naeluh naeluh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great !!

@jds-tag jds-tag merged commit c4178a2 into master Jan 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants