-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
51 lines (44 loc) · 1.28 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
const gulp = require('gulp');
const sync = require('run-sequence');
const browser = require('browser-sync');
const webpack = require('webpack-stream');
const eslint = require('gulp-eslint');
const paths = {
entry: 'client/app/app.js',
app: ['client/app/**/*.{js,less,html}', 'client/styles/**/*.less'],
js: 'client/app/**/*!(.spec.js).js',
less: ['client/app/**/*.less', 'client/style/**/*.less'],
toCopy: ['client/index.html', 'client/assets/images/*'],
html: ['client/index.html', 'client/app/**/*.html'],
dest: 'dist'
};
gulp.task('lint', () => gulp.src(['client/app/**/*.js'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError())
);
gulp.task('build', ['lint'], () => gulp.src(paths.entry)
.pipe(webpack(require('./webpack.config')))
.pipe(gulp.dest(paths.dest))
);
gulp.task('serve', () => {
browser({
port: process.env.PORT || 4500,
open: false,
ghostMode: false,
server: {
baseDir: 'dist'
}
});
});
gulp.task('copy', () => gulp
.src(paths.toCopy, { base: 'client/' })
.pipe(gulp.dest(paths.dest))
);
gulp.task('watch', () => {
gulp.watch(paths.app, ['build', browser.reload]);
gulp.watch(paths.toCopy, ['copy', browser.reload]);
});
gulp.task('default', (done) => {
sync('build', 'copy', 'serve', 'watch', done);
});