-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
123 lines (107 loc) · 2.64 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
const gulp = require("gulp"),
path = require('path'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
cssmin = require('gulp-cssmin'),
watch = require('gulp-watch'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
plumber = require('gulp-plumber'),
del = require('del'),
runSequence = require('run-sequence'),
browserSync = require("browser-sync"),
exec = require('child_process').execSync;
/**
* File Path
*/
const ROOT = __dirname;
const SRC_PATH = path.join(ROOT, './src');
const PUBLIC_PATH = path.join(ROOT, './public');
// HTML
const HTML_SRC_PATH = path.join(SRC_PATH, 'html');
const HTML_FILES = path.join(HTML_SRC_PATH, './**/*.html');
// SASS
const SASS_SRC_PATH = path.join(SRC_PATH, 'scss');
const SASS_FILES = path.join(SASS_SRC_PATH, './**/*.scss');
const CSS_FILES = path.join(PUBLIC_PATH, './css/**/*.css');
// Clean Task
gulp.task('clean.release', function() {
return del([CSS_FILES], {force: true});
});
// HTML
gulp.task('html', function() {
return gulp.src([HTML_FILES]).pipe(gulp.dest(PUBLIC_PATH));
});
// Sass, CSS
gulp.task('sass', function() {
return gulp.src([SASS_FILES])
.pipe(sass({
outputStyle: 'expanded'
}).on('error', sass.logError))
.pipe(gulp.dest(PUBLIC_PATH + '/css'));
});
gulp.task('css.prefixer', function() {
return gulp.src([CSS_FILES])
.pipe(autoprefixer({
browsers: ['last 2 versions', 'ie 8', 'ios 6', 'android 2.3'],
cascade: false
}))
.pipe(gulp.dest(PUBLIC_PATH + '/css'));
});
gulp.task('css.min', function() {
return gulp.src([CSS_FILES])
.pipe(cssmin())
.pipe(gulp.dest(PUBLIC_PATH + '/css'));
});
// ファイル更新監視
gulp.task('watch', function() {
// HTML
gulp.watch([HTML_FILES], ['html']);
// SCSS
gulp.watch([SASS_FILES], ['build.css']);
});
gulp.task('browser-sync', function() {
browserSync({
server: "./public",
files: ["./public/**"],
port: 8080
});
browserSync.reload();
});
/**
* Build Task
**/
gulp.task('build.ui', function(callback) {
return runSequence(
['html', 'build.css'],
callback
);
});
gulp.task('build.css', function(callback) {
return runSequence(
'sass',
'css.prefixer',
'css.min',
callback
);
});
/**
* Dist Task
**/
gulp.task('dist', function(callback) {
return runSequence(
'build.ui',
callback
);
});
/**
* default Task
**/
gulp.task('default', function(callback) {
runSequence(
'build.ui',
'watch',
'browser-sync',
callback
);
});