-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
72 lines (65 loc) · 2.12 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
var gulp = require("gulp");
var gutil = require("gulp-util");
var del = require('del');
var path = require('path');
var webpack = require("webpack");
var WebpackDevServer = require("webpack-dev-server");
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ghPages = require('gulp-gh-pages');
var config = {
buildDir: 'build',
entry: './app/js/main.js',
bundle: 'app.js',
title: 'thompson-regex-js'
}
var webpackConfig = {
entry: config.entry,
output: {
path: path.join(__dirname, config.buildDir),
filename: config.bundle
},
module: {
loaders: [
{ test: /\.css$/, loader: "style!css" },
{ test: /\.js$/, loader: "jsx-loader" },
{ test: /\.json$/, loader: "json-loader" },
{ test: /\.jsx$/, loader: "jsx-loader?insertPragma=React.DOM" },
{ test: /\.woff$/, loader: "url-loader?prefix=font/&limit=5000&mimetype=application/font-woff" },
{ test: /\.woff2$/, loader: "url-loader?prefix=font/&limit=5000&mimetype=application/font-woff2" },
{ test: /\.ttf$/, loader: "file-loader?prefix=font/" },
{ test: /\.eot$/, loader: "file-loader?prefix=font/" },
{ test: /\.svg$/, loader: "file-loader?prefix=font/" }
]
},
plugins: [
new HtmlWebpackPlugin({
title: config.title,
filename: 'index.html'
})
]
};
gulp.task('clean', function(callback) {
del([config.buildDir], callback);
});
gulp.task('webpack', function(callback) {
webpack(webpackConfig, function(err, stats) {
if (err) throw new gutil.PluginError("webpack", err);
gutil.log("[webpack]", stats.toString());
callback();
});
});
gulp.task('webpack-dev-server', function(callback) {
var myConfig = Object.create(webpackConfig);
myConfig.devtool = "eval";
myConfig.debug = true;
var wp = webpack(myConfig);
new WebpackDevServer(wp).listen(8080, "localhost", function(err) {
if(err) throw new gutil.PluginError("webpack-dev-server", err);
gutil.log("[webpack-dev-server]", "http://localhost:8080");
});
});
gulp.task('default', ['webpack-dev-server']);
gulp.task('ghPages', ['webpack'], function() {
return gulp.src('./build/**/*')
.pipe(ghPages());
});