diff options
| author | Mathias Biilmann Christensen <info@mathias-biilmann.net> | 2016-07-03 15:07:47 -0700 |
|---|---|---|
| committer | Mathias Biilmann Christensen <info@mathias-biilmann.net> | 2016-07-03 15:07:47 -0700 |
| commit | 8f6c70c51bf7e9e2045ae13c4052156877e77648 (patch) | |
| tree | d17454781e9cf316e76721c08397ed5fe772d125 /gulpfile.babel.js | |
Basic setup - gulp + webpack + hugo
Diffstat (limited to 'gulpfile.babel.js')
| -rw-r--r-- | gulpfile.babel.js | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/gulpfile.babel.js b/gulpfile.babel.js new file mode 100644 index 0000000..5de71c9 --- /dev/null +++ b/gulpfile.babel.js @@ -0,0 +1,54 @@ +import gulp from 'gulp'; +import babel from 'gulp-babel'; +import cp from 'child_process'; +import gutil from 'gulp-util'; +import webpack from 'webpack'; +import webpackConfig from './webpack.conf'; +import WebpackDevServer from 'webpack-dev-server'; + + +gulp.task('hugo', (cb) => { + const args = ['-d', '../dist', '-s', 'site']; + return cp.spawn('hugo', args, {stdio: 'inherit'}).on('close', cb); +}); + +gulp.task('webpack', (cb) => { + const myConfig = Object.assign({}, webpackConfig); + + // run webpack + webpack(myConfig, (err, stats) => { + if (err) throw new gutil.PluginError('webpack', err); + gutil.log('[webpack]', stats.toString({ + colors: true, + progress: true + })); + cb(); + }); +}); + +gulp.task('build', ['webpack', 'hugo']); + +gulp.task('server', ['build'], (cb) => { + gulp.watch('site/**', ['hugo']); + + const myConfig = Object.assign({}, webpackConfig); + myConfig.devtool = 'cheap-module-eval-source-map'; + myConfig.debug = true; + + for (const key in myConfig.entry) { + myConfig.entry[key].unshift("webpack-dev-server/client?http://localhost:3009/"); + } + + // Start a webpack-dev-server + new WebpackDevServer(webpack(myConfig), { + contentBase: './dist', + publicPath: 'http://localhost:3009/', + stats: { + colors: true + }, + hot: false + }).listen(3009, 'localhost', function(err) { + if(err) throw new gutil.PluginError('webpack-dev-server', err); + gutil.log('[webpack-dev-server]', 'http://localhost:3009/'); + }); +}); |
