1

I'm using babel from gulp to attempt to create React code.

When I run babel either from gulp or just from the commandline, the output of my code is exactly the same as the input. Nothing is changed.

This is my babel.config.js

const presets = [
    [
        "@babel-env",
        {
            targets : {
                edge : "17",
                ie  : "8",
                firefox : "60",
                chrome : "67",
                safari : "11.1"
            },
            useBuiltIns: "usage"
        }
    ],
]

This is the contents of the file I want to transform:

import React from 'react' ;
import ReactDOM from 'react-dom';

console.log("starting...");

const foo = "foo" ;
const bar = "bar"

const testFn =  (foo, bar) => {
    console.log("in testFn");
}

This is my task definition:

gulp.task('scripts', function() {
    return gulp.src(['./src/js/main.js' ])
        .pipe(babel({
            presets : ['@babel/preset-react']
        }))
        .pipe(concat('test.js'))
        .pipe(gulp.dest('./dist/js'))
        .pipe(terser())
        .pipe(rename('test.min.js'))
        .pipe(gulp.dest('./dist/js')) ;
});

How do I get babel to do its job?

bob
  • 753
  • 4
  • 15
  • 27

0 Answers0