-
-
Save bolasblack/7c45314b790f35b5632f146a9cebb0ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const webpack = require('webpack'); | |
const webpackDevServer = require("webpack-dev-server"); | |
const gulp = require('gulp'); | |
const gulp_util = require('gulp-util'); | |
const webpackConfig = require('./webpack.config'); | |
const webpackCompiler = webpack(webpackConfig); | |
gulp.task('watch', function(callback) { | |
const devServer = new webpackDevServer(webpackCompiler, { | |
hot: true, | |
contentBase: "./public/", | |
watchOptions: { | |
aggregateTimeout: 100, | |
poll: 300 | |
}, | |
stats: { | |
colors: true, | |
chunks: false | |
} | |
}); | |
devServer.listen(9090, "127.0.0.1", function(err) { | |
if (err) { | |
throw new gulp_util.PluginError("webpack-dev-server", err); | |
} | |
return gulp_util.log("webpack-dev-server started at http://127.0.0.1:9090"); | |
}); | |
}); | |
gulp.task('default', ['watch']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log('hello world') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "webpack-with-gulp", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1", | |
"start": "gulp" | |
}, | |
"author": "", | |
"license": "ISC", | |
"devDependencies": { | |
"gulp": "3.9.1", | |
"gulp-util": "3.0.7", | |
"webpack": "1.13.2", | |
"webpack-dev-server": "1.16.1" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sysPath = require('path'); | |
const webpack = require('webpack'); | |
config = { | |
entry: [ | |
"webpack-dev-server/client?http://127.0.0.1:9090", | |
'./index.js', | |
"webpack/hot/dev-server" | |
], | |
resolveLoader: { | |
modulesDirectories: ['node_modules'] | |
}, | |
resolve: { | |
extensions: ['', '.js'] | |
}, | |
module: { | |
loaders: [] | |
}, | |
plugins: [new webpack.HotModuleReplacementPlugin()], | |
output: { | |
path: sysPath.resolve('./public'), | |
filename: '[name].js' | |
} | |
}; | |
module.exports = config; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment