-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.babel.js
More file actions
60 lines (51 loc) · 1.66 KB
/
gulpfile.babel.js
File metadata and controls
60 lines (51 loc) · 1.66 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
import bg from 'gulp-bg';
import eslint from 'gulp-eslint';
import fs from 'fs';
import gulp from 'gulp';
import makeWebpackConfig from './webpack/makeconfig';
import rename from 'gulp-rename';
import webpackBuild from './webpack/build';
import webpackDevServer from './webpack/devserver';
import yargs from 'yargs';
var args = yargs
.alias('p', 'production')
.argv;
gulp.task('env', () => {
const env = args.production ? 'production' : 'development';
process.env.NODE_ENV = env; // eslint-disable-line no-undef
});
gulp.task('local-config', () => {
var configDir = './src/config/';
var localConfigClient = 'config.client.local.js';
var localConfigServer = 'config.server.local.js';
var sampleConfig = 'config.sample.js';
if (!fs.existsSync(configDir + localConfigClient)) {
gulp.src(configDir + sampleConfig)
.pipe(rename(localConfigClient))
.pipe(gulp.dest(configDir));
}
if (!fs.existsSync(configDir + localConfigServer)) {
gulp.src(configDir + sampleConfig)
.pipe(rename(localConfigServer))
.pipe(gulp.dest(configDir));
}
});
gulp.task('build-webpack-production', webpackBuild(makeWebpackConfig(false)));
gulp.task('build-webpack-dev', webpackDevServer(makeWebpackConfig(true)));
gulp.task('build-webpack', [args.production
? 'build-webpack-production'
: 'build-webpack-dev'
]);
gulp.task('build', ['local-config', 'build-webpack']);
gulp.task('eslint', () => {
return gulp.src([
'gulpfile.js',
'src/**/*.js',
'webpack/*.js'
])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failOnError());
});
gulp.task('server', ['env', 'build'], bg('node', 'src/server'));
gulp.task('default', ['server']);