This repository was archived by the owner on Jan 5, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
81 lines (69 loc) · 2.33 KB
/
Copy pathgulpfile.js
File metadata and controls
81 lines (69 loc) · 2.33 KB
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
73
74
75
76
77
78
79
80
81
const gulp = require("gulp");
const gutil = require("gulp-util");
const webpack = require("webpack");
const gulpWebpack = require('gulp-webpack');
const WebpackDevServer = require("webpack-dev-server");
const rimraf = require('rimraf');
const mocha = require('gulp-mocha');
const babel = require('gulp-babel');
const sourcemaps = require('gulp-sourcemaps');
const ghPages = require('gulp-gh-pages');
const webpackConfig = require('./webpack.config');
const webpackProdConfig = require('./webpack.config.prod');
gulp.task("webpack", ['clean'], function () {
return gulp.src('app/main.js')
.pipe(gulpWebpack(webpackProdConfig))
.pipe(gulp.dest('dist/'));
});
gulp.task("webpack-dev-server", ['prepare'], function (callback) {
// Start a webpack-dev-server
var compiler = webpack(webpackConfig);
new WebpackDevServer(compiler, {
historyApiFallback: true
// server and middleware options
}).listen(9000, "localhost", function (err) {
if (err) throw new gutil.PluginError("webpack-dev-server", err);
// Server listening
gutil.log("[webpack-dev-server]", "http://localhost:9000/webpack-dev-server/index.html");
// keep the server alive or continue?
// callback();
});
});
gulp.task('clean', function (cb) {
rimraf('./dist', cb);
});
gulp.task('prepare', function () {
gulp.src('./app/assets/favicon.ico')
.pipe(gulp.dest('./dist/'));
});
gulp.task('compile-test', function () {
return gulp.src('spec/**/*.js')
.pipe(sourcemaps.init())
.pipe(babel({
presets: ['es2015', 'stage-1', 'stage-0'],
plugins: ['transform-runtime', 'add-module-exports', 'transform-decorators-legacy']
}))
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist/spec'));
});
gulp.task('test', ['compile', 'compile-test'], function () {
return gulp.src('dist/spec/**/*.js', {read: false})
.pipe(mocha({
reporter: 'spec'
}));
});
gulp.task('compile', function () {
return gulp.src('app/**/*.js')
.pipe(sourcemaps.init())
.pipe(babel({
presets: ['es2015', 'stage-1', 'stage-0', 'react'],
plugins: ['transform-runtime', 'add-module-exports', 'transform-decorators-legacy']
}))
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist/app'));
});
gulp.task('deploy', ['webpack'], function () {
return gulp.src('./dist/**/*')
.pipe(ghPages());
});
gulp.task('default', ['webpack']);