问题
Is there a way to run a Gulp task on Webstorm launch?
Tried looking through webstorm settings but don't see anything, also Gulp integration is brand new to Webstorm 9.
gulp.task('watch', function () {
gulp.watch(paths.watch.css, function(){ compileLESS(paths.src.css, paths.dest.css, {name: 'Style'}) });
gulp.watch(paths.watch.cssBootstrap, function(){ compileLESS(paths.src.cssBootstrap ,paths.dest.cssBootstrap, {suffix: '.min', name: 'Bootstrap'}) });
gulp.watch(paths.watch.scripts, ['scripts']);
gulp.watch(paths.watch.libraries, ['libraries']);
});
Just want a way to run Gulp 'watch' (if the project has gulp and a task called watch) when ever i start Webstorm.
回答1:
No:( WebStorm (as well as other JetBrains IDEs) doesn't support 'on launch' actions - see https://youtrack.jetbrains.com/issue/WEB-11818#comment=27-787220
回答2:
As of WebStorm 11, this is possible.
- Settings > Tools > Startup Tasks
- Hit the green plus icon to
Add New Configuration
- Choose
Gulp.js
- Choose your tasks that you want to run from the
Tasks:
dropdown
Done!
回答3:
Best thing to do is set your gulp task (which sets up the watchers) as a 'before launch' task of your main configuration.
Works great for me. I need to start my server before I can start developing, and when I do, I know this will start my watchers and do any necessary processing for the first time.
来源:https://stackoverflow.com/questions/26484710/autorun-gulp-task-watch-on-webstorm-launch