Babel and grunt-watch
See original GitHub issueHello!
I’ve got a project that uses connect -> watch -> babel in the dev environment. When I first run grunt server
, it transpiles the es6->js successfully.
The watch works in that it sees changes to the es6 file and runs the babel tasks. The js file changes somehow, because grunt sees a change and refreshes the page with livereload, but the changes to the es6 file are not reflected in the js file.
My inexperienced assumption is that the js file is being rewritten, but without the new changes to the es6 file. Any thoughts?
A truncated copy of my gruntfile:
grunt.registerTask('server', [
'sass',
'babel',
'connect:server',
'watch'
]);
grunt.initConfig({
babel: {
options: {
sourceMap: true
},
all: {
files: [{
expand: true,
cwd: 'dev/js/site',
src: ['**/*.es6'],
dest: 'dev/js/site',
ext: '.js'
}]
}
},
watch: {
livereload: {
options: { livereload: true },
files: ['dev/css/*.css', 'dev/js/site/*.js', 'dev/**/*.html']
},
sass: {
files: 'dev/scss/*.scss',
tasks: ['sass']
},
babel: {
files: 'dev/js/site/*.es6',
tasks: ['babel']
}
},
connect: {
server: {
options: {
port: 8888,
hostname: '*',
livereload: true,
open: true,
base: 'dev'
}
}
}
}
Issue Analytics
- State:
- Created 9 years ago
- Comments:5
Top Results From Across the Web
Implementing Babel via Grunt - Utah GIS
Add the new babel and copy tasks to the watch task config. Using grunt-newer will make things more efficient.
Read more >Using Babel + grunt to work with ES6 - how to transform ...
I am already using babel, see the line grunt.registerTask('default', ['babel', 'jshint', 'concat', 'uglify']) in the gruntfile. Do ...
Read more >How use Babel with Grunt - The freeCodeCamp Forum
Hi, I have this warning: warning: Task "babel" not found. ... OK + sass Registering "grunt-contrib-watch" local Npm module tasks.
Read more >ECMAScript 6 Development Today with Babel and Grunt
It's a transpiler that can turn new syntax of ES6 to an ES5 construct that ... You can start the task by typing...
Read more >grunt-babel - npm
Use next generation JavaScript, today. Latest version: 8.0.0, last published: 4 years ago. Start using grunt-babel in your project by ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yep. You’re right. I had to specify the specific babel task in the watch. Odd, but works for me. Thanks!
Thanks @mmahalwy, it works!