D
D
Dmitry Markov2019-12-05 17:04:52
gulp.js
Dmitry Markov, 2019-12-05 17:04:52

How to set up babel in gulp?

gulp.js

const babel = 			require("rollup-plugin-babel");
const rollup = 			require("rollup-stream");

gulp.task("js", function () {
  return rollup({
    input: "./src/js/index.js",
    sourcemap: false,
    format: 'es',
    plugins: [babel()]
  })
  .pipe(gulp.dest('static/js/'));
});

.babelrc
{
  "presets": [
    [
    "env",
    {
      "modules": false
    }
    ]
  ],
  "plugins": [
    "external-helpers"
  ]
  }

package.json
{
  "name": "project",
  "version": "1.0.0",
  "description": "",
  "main": "gulpfile.js",
  "dependencies": {
    "gulp": "^3.9.1",
    "gulp-autoprefixer": "^4.1.0",
    "gulp-base64": "^0.1.3",
    "gulp-changed": "^3.1.1",
    "gulp-cheerio": "^0.6.3",
    "gulp-concat": "^2.6.1",
    "gulp-connect": "^5.0.0",
    "gulp-csso": "^3.0.1",
    "gulp-nodemon": "^2.2.1",
    "gulp-notify": "^3.2.0",
    "gulp-plumber": "^1.2.1",
    "gulp-pug": "^3.3.0",
    "gulp-pug-inheritance": "^0.2.1",
    "gulp-replace": "^0.6.1",
    "gulp-sass": "^3.1.0",
    "gulp-sourcemaps": "^2.6.4",
    "gulp-svg-sprites": "^4.1.2",
    "gulp-tinypng-compress": "^1.2.1",
    "gulp-uglify": "^3.0.1",
    "gulp-watch": "^4.3.11",
    "natives": "^1.1.6",
    "responsively-lazy": "^2.0.2"
  },
  "devDependencies": {
    "babel-core": "^6.26.3",
    "babel-plugin-external-helpers": "^6.22.0",
    "babel-preset-env": "^1.7.0",
    "rollup-plugin-babel": "^3.0.7"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

Error in console
5de90e751586e521801308.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question