There are two ways to compiler the ES6 fils to Javascript file.
One:
traceur --out build/app.js --script js/app.js --experimental
Two:
Using grunt.
Install:
npm install -g traceur npm install grunt-contrib-watch npm install grunt-traceur-latest
GruntFile:
module.exports = function(grunt){ grunt.initConfig({ traceur: { options: { experimental:true }, custom: { files:{ ‘build/app.js‘: "js/**/*.js" } } }, watch: { files:"js/**/*.js", tasks: "traceur" } }); grunt.loadNpmTasks(‘grunt-traceur-latest‘); grunt.loadNpmTasks(‘grunt-contrib-watch‘); }
时间: 2024-10-01 11:23:30