Sublime Forum

Transpile ES6 to ES5 on save

#1

With the Less plugin I got a nice Less -> Css compilation whenever I save the file. How to get the same behavior with Babel to have ES6 code transpiled to ES5? Thanks

0 Likes

#2

Seems like you could just copy the Less plugin, find the part in it that does the transpiling, and replace it with an ES transpiler.

0 Likes

#3

If you’re doing Babel (or whatever) transpiling that you want to keep updated live, you probably don’t want it to be a Sublime plugin at all. This is a common build task, and one normally uses the ‘watch’ (or equivalent) method in a JS build library like Gulp, Grunt, Broccoli, or (personal favorite) Gobble. That way it will also be updated even if you’re editing outside of Sublime, or you’ve just pulled from your repo, etc – and, if it makes sense, you can also tie it into automatically restarting the application on build.

But then take this advice with a grain of salt, since I also wouldn’t let my editor handle rendering LESS to CSS for the same reason – these build behaviors should be part of the project proper, not tied to a machine-specific development environment. That may not matter if you’re certain nobody else will ever have to edit your code.

0 Likes