-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.local.js
72 lines (64 loc) · 1.63 KB
/
gulpfile.local.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 webpack = require('gulp-webpack');
var webserver = require('gulp-webserver');
var preprocess = require('gulp-preprocess');
var webpackConfig = require('./webpack.config.js');
var debug = require('gulp-debug');
var karma = require('gulp-karma');
var gulpif = require('gulp-if');
var _create = require('lodash.create');
var argv = require('yargs').argv;
var files = {
watch: [
'app/routes.js',
'app/main.js',
'app/components/**/*.js',
'app/components/**/*.scss',
'app/components/**/*.svg',
'app/actions/*.js',
'app/stores/*.js',
'app/utils/*.js'
],
index: './index.html',
main: './app/main.js'
}
// ***
// Build index file
// ***
gulp.task('build-index', function() {
return gulp.src(files.index)
.pipe(gulp.dest('dist/'));
});
gulp.task('watch-index', ['build-index'], function() {
return gulp.watch(files.index, ['build-index']);
});
// ***
// Build local files
// ***
gulp.task('build-local-js', function() {
var config = _create(webpackConfig, {
entry: {
main: files.main
}
});
return gulp.src(files.main)
.pipe(webpack(config))
.pipe(gulpif(argv.testdata,
preprocess({context: {ENV: 'test'}}),
preprocess({context: {ENV: 'local'}}))
)
.pipe(gulp.dest('dist/'));
});
gulp.task('watch-local', ['build-local-js'], function() {
return gulp.watch(files.watch, ['build-local-js']);
});
// ***
// Main tasks
// ***
gulp.task('local', ['watch-index', 'watch-local'], function() {
return gulp.src('dist/')
.pipe(webserver({
livereload: true,
open: 'http://localhost:8000/#/projects'
}));
});