Skip to content

Instantly share code, notes, and snippets.

@cema-sp
Created February 2, 2016 11:11
Show Gist options
  • Save cema-sp/0b34724ecf1fe6a95398 to your computer and use it in GitHub Desktop.
Save cema-sp/0b34724ecf1fe6a95398 to your computer and use it in GitHub Desktop.
Gulp task for webpack-dev-server
gulp = require 'gulp'
util = require 'gulp-util'
webpack = require 'webpack'
WebpackDevServer = require 'webpack-dev-server'
webpackConfig = require '../../../config/webpack.js'
gulp.task 'webpack-dev-server', (callback) ->
# Start a webpack-dev-server
myConfig = Object.create webpackConfig
compiler = webpack myConfig
devServer = new WebpackDevServer(compiler, {
publicPath: myConfig.output.publicPath,
# historyApiFallback: true,
stats: { colors: true },
headers: {
'Access-Control-Allow-Origin': 'http://localhost:3000',
'Access-Control-Allow-Credentials': 'true'
},
hot: true,
watchOptions: {
aggregateTimeout: 300,
poll: 1000
}
}).listen 8080, "localhost", (err) ->
throw new util.PluginError("webpack-dev-server", err) if err
# Server listening
util.log util.colors.bgGreen(util.colors.black "[webpack-dev-server]"),
"http://localhost:8080/webpack-dev-server/public/assets/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment