 # -----------------------------------------------------------------------
 #  Build Javascript and Styles using webpack
 # -----------------------------------------------------------------------
+gulp.task '_cleanDist', (done) ->
+  del(['./dist/*'], done)
 
-
-gulp.task '_build', (done) ->
-  webpack(webpackConfig, (err, stats) ->
+gulp.task '_build', ['_cleanDist'], (done) ->
+  config = _.extend({}, webpackConfig, {
+    plugins: [
+      new ExtractTextPlugin("tutor.min.css")
+    ]
+  })
+  config.output.filename = 'tutor.min.js'
+  webpack(config, (err, stats) ->
     throw new gutil.PluginError("webpack", err) if err
     gutil.log("[webpack]", stats.toString({
       # output options

webpack         = require 'webpack'
webpackConfig   = require './webpack.config'
webpackServer   = require 'webpack-dev-server'
_ = require 'underscore'

KARMA_CONFIG =
  configFile: __dirname + '/test/karma.config.coffee'

  server = new karma.Server(config)
  server.start()

# same as TDD, not sure if anyone uses 'dev' ?
gulp.task 'dev', ['tdd']

gulp.task 'tdd', ['_cleanDist', '_webserver', '_karma']
