int22h
@int22h

Gulp не запускает таск после изменений, почему?

Используется gulp+webpack+coffee.
Gulp настроен чтобы следить за изменениями в coffee файлах и компилировать их в js.
Проблема после запуска watch.
Если в папке client/ сделать ошибку в coffee файле, то она появится в консоли и все хорошо.
Но после исправления ошибки не запускается таск gulp.run 'client coffee'.

Со всем этим добром работаю впервые, по этому пока не могу понять что не так.
Собственно сам код:

coffee  = require 'gulp-coffee'
concat  = require 'gulp-concat'
gutil   = require 'gulp-util'
gulp = require 'gulp'
babel = require('gulp-babel')
webpack = require('webpack')
path = require('path')
watch = require 'gulp-watch'
shell = require('gulp-shell')

isProduction = gutil.env.production

build = (watch, callback) ->
  plugins = [ new (webpack.DefinePlugin)('process.env.NODE_ENV': JSON.stringify(if isProduction then 'production' else 'development')) ]
  if isProduction
    plugins.push new (webpack.optimize.UglifyJsPlugin)

  webpack 
    plugins: plugins
    cache: true
    watch: watch
    module: {
      loaders: [
        { test: /\.json$/, loader: 'json-loader' }
        { test: /\.js?$/, exclude: /node_modules/, loader: 'babel-loader' }       
        {
          test: /\.scss$/,
          use: [
            {
              loader: 'style-loader'
            }, 
            {
              loader: 'css-loader'
              #query: {
              #  modules: true,
              #  localIdentName: '[name]__[local]___[hash:base64:5]'
              #}
            },
            {
              loader: "sass-loader" 
            }
          ]        
        }
      ]
    },
    devtool: '#source-map'
    entry: path.resolve(__dirname, 'client/js/app-route.js')
    output:
      filename: 'app.js'
      path: path.resolve(__dirname, 'client/dist')
  , (err, stats) ->
    console.log "Error: #{ err}" if err?
    if callback
      callback()
    return
  return



gulp.task 'common coffee', ->
  gulp.src ['common/**/*.coffee'], {sourcemaps: true}
  .pipe coffee {bare: true}
  .pipe gulp.dest "common/"
  .on 'error', gutil.log

gulp.task 'generate api', shell.task 'lb export-api-def --json -o ./client/js/api.json'
  
gulp.task 'server coffee', ->  
  gulp.src 'server/**/*.coffee', {sourcemaps: true}
  .pipe coffee {bare: true}
  .pipe gulp.dest "server/"
  .on 'error', gutil.log
  

gulp.task 'client coffee', ->
  console.log "client coffee task"
  gulp.src 'client/**/*.coffee', {sourcemaps: false}
  .pipe(coffee({bare: true, coffee: require 'coffeescript'}).on('error', gutil.log))
  .pipe(babel({presets: ['env']}))
  .pipe gulp.dest "client/"
  .on 'error', gutil.log
  .on 'finish', ->
    gulp.run 'webpack build'
    
gulp.task 'webpack build', ->
  build false, ->
    console.log "Build returned"  
    
gulp.task 'default', ->
  gulp.run 'common coffee'
  gulp.run 'server coffee'
  gulp.run 'generate api'
  gulp.run 'client coffee'

gulp.task 'client', ->
  gulp.run 'client coffee'  

gulp.task 'watch', ->
  watch ['common/**/*.coffee', 'common/**/*.json'], ->
    gulp.run 'common coffee'
    gulp.run 'generate api'  
  watch 'server/**/*.coffee', ->
    gulp.run 'server coffee'
  watch 'client/admin/**/*.coffee', ->
    console.log "ADMIN PANEL CHANGED"
    gulp.run 'client coffee'
  watch ['client/js/**/*.coffee', "client/js/**/*.scss"], ->
    console.log "client changed"
    gulp.run 'client coffee'
  • Вопрос задан
  • 305 просмотров
Пригласить эксперта
Ответы на вопрос 2
@cache0
после ошибок таск с ватчем заного надо запускать
Ответ написан
int22h
@int22h Автор вопроса
нашел решение здесь

https://gist.github.com/floatdrop/8269868

вдруг кому надо будет
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы