Is it possible write a gulpfile in es6?

前端 未结 6 2062
终归单人心
终归单人心 2020-12-23 09:52

Question: How can I write my gulp file in ES6 so I can use import instead of require and use => syntax over

6条回答
  •  遥遥无期
    2020-12-23 09:57

    Steps I followed for developing the code for gulpfile in es6:

    • npm install gulp && sudo npm install gulp -g.
    • Please make sure that you you are using the updated version of Gulp. The current version at the time of writing this answer was 3.9.1. To check which version of gulp is installed, type gulp -v
    • npm install babel-core babel-preset-es2015-without-strict --save-dev
    • Type touch .babelrc in the terminal
    • In the .babelrc file, add this code

      { "presets": ["es2015-without-strict"] }

    • Created the gulp config file with the name gulpfile.babel.js

    • Voila!!! You can now write the config code for gulp in ES6.

    Source: Using ES6 with Gulp - Mark Goodyear

提交回复
热议问题