Use Gulp to build ES6 operating environment

Source: Internet
Author: User

ES6 introduced a lot of new syntax features, but want to do in the existing browser environment, need to ES6 code to ES5 code, there are many transcoding babel,traceur, etc., after reference, use Traceur and gulp to build ES6 environment, start my ES6 .Start installation

First make sure the Nodejs is installed on your computer.
1. Create a project directory
2. Global installation traceur, in console input
NPM install-g traceur
3. Open the project directory, install the Gulp and the Gulp-traceur plugin
NPM Install-g Gulp
NPM Install Gulp Gulp-traceur–save-dev
4. Create the Package.json file NPM init, create the gulpfile.js in the project root directory

 
var gulp = require (' gulp '); var browsersync = require (' Browser-sync '). Create (); var traceur = require (' gulp-traceur ');// Static Server + watching scss/html filesgulp.task (' Serve ', [' traceur '], function () {    browsersync.init ({     Server : "./"     });    Gulp.watch ("Build/**/*.js", [' traceur ');}); Gulp.task (' Traceur ', function () {    return gulp.src (' Build/*.js ')        . Pipe (Traceur ({exprimental:true}))        . Pipe (gulp.dest (' JS ');}); Gulp.task (' Default ', [' serve ']);

  

5. Run gulp, when the content in the build folder written with ES6 syntax changes, the Traceur task executes and uses Browser-sync to make the browser respond to file changes in real time (HTML, JS, CSS, SASS, Less) and automatically refresh the page.
6. Start the use of ES6.

Reference articles
Several ways to use ES6 in 1.WebStorm (http://www.cnblogs.com/darrenji/p/4997045.html)
2.browser-sync (http://www.browsersync.cn/).

Use Gulp to build ES6 operating environment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.