-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
57 lines (50 loc) · 1.46 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
var gulp = require('gulp');
var connect = require('gulp-connect');
var mocha = require('gulp-mocha');
var plumber = require('gulp-plumber');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
gulp.task('serve', function() {
return connect.server({
root: 'dist',
port : 3000,
livereload: true
});
});
gulp.task("move-html", function(){
return gulp.src(["./src/html/**/*.html"])
.pipe(plumber())
.pipe(gulp.dest("dist"));
});
gulp.task('move-img',function(){
return gulp.src(['./graphics/**/*.svg'])
.pipe( gulp.dest('dist/images') );
});
gulp.task('move-css',function(){
return gulp.src(['./css/**/*.css'])
.pipe( gulp.dest('dist/css') );
});
gulp.task('script', function() {
browserify({
entries: ['./src/main.js'],
debug: true
})
.bundle()
.on('error', function(err){ //ここからエラーだった時の記述
console.log(err);
})
.pipe(source('main.js'))
.pipe(buffer())
// .pipe(uglify())
.pipe(gulp.dest("./dist/"))
});
gulp.task('watch',function(){
gulp.watch(["src/**/*.js"],["script"]);
gulp.watch(["graphics/**/*.svg"],["move-img"]);
gulp.watch(["src/**/*.html"],["move-html"]);
gulp.watch(["css/**/*.css"],["move-css"]);
});
var buildTasks = ['script', 'move-img', 'move-html', 'move-css'];
gulp.task('build', buildTasks);
gulp.task('default', buildTasks.concat(['serve', 'watch']));