Autorun Gulp task 'watch' on Webstorm laun

2019-06-02 09:06发布

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.

标签: gulp WebStorm
3条回答
放我归山
2楼-- · 2019-06-02 09:43

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.

查看更多
成全新的幸福
3楼-- · 2019-06-02 09:44

As of WebStorm 11, this is possible.

  1. Settings > Tools > Startup Tasks
  2. Hit the green plus icon to Add New Configuration
  3. Choose Gulp.js
  4. Choose your tasks that you want to run from the Tasks: dropdown

Done!

查看更多
甜甜的少女心
4楼-- · 2019-06-02 09:54

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

查看更多
登录 后发表回答