Grunt Babel Taking 6 Seconds Per File
I'm trying to use Babel in my grunt build process to transpile my .js project files from ES6 to ES5. I have a watch task watching my .js directory for changes and when changes are
Solution 1:
During development you can decide to run the JS version of the Babel-core directly in the browser, which runs quite fast.
Then for deployment you can make a specific Grunt build task that removes the Babel-Core from the HTML and instead transpiles the files with the Grunt Babel plugin.
Your Gruntfile will have something like this:
grunt.registerTask('build', ['processhtml', 'babel']);
grunt.registerTask('default', [''watch']);
For the removal of the Babel-core JS you can use plugins like like grunt-processhtml: http://www.npmjs.com/package/grunt-processhtml . The HTML will look like this:
<!-- build:remove --><scripttype="text/javascript"src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/6.1.19/browser.min.js"></script><!-- /build -->
The JS Babel-core can found here: http://cdnjs.com/libraries/babel-core . You can download it and add it to your project or just run it from the CDN directly.
Post a Comment for "Grunt Babel Taking 6 Seconds Per File"