-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
49 lines (42 loc) · 1.24 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
const gulp = require('gulp')
const sass = require('gulp-sass')
const plumber = require('gulp-plumber')
const notify = require('gulp-notify')
// const runSequence = require('run-sequence')
const webpack = require('webpack')
const webpackStream = require('webpack-stream')
const webpackConfig = require('./webpack.config')
const del = require('del')
require('dotenv')
const env = process.env.KINTONE_ENV === 'development' ? 'dev' : 'prod'
const paths = {
'js': './src/**/*.js',
'sass': './src/styles/*.+(sass|scss)',
'dist': './dist/' + env
}
// clean
gulp.task('clean', () => {
del([paths.dist])
})
// js
gulp.task('js', () => {
return gulp.src([paths.js])
.pipe(plumber({errorHandler: notify.onError('<%= error.message %>')}))
.pipe(webpackStream(webpackConfig, webpack))
.pipe(gulp.dest(paths.dist + '/js'))
})
// sass
gulp.task('sass', () => {
return gulp.src([paths.sass])
// .pipe(filter(['**/styles/*.(sass|scss)'], {restore: true}))
.pipe(plumber({errorHandler: notify.onError('<%= error.message %>')}))
.pipe(sass())
.pipe(gulp.dest(paths.dist + '/css'))
})
// watch
gulp.task('watch', () => {
gulp.watch(paths.js, ['js'])
gulp.watch(paths.sass, ['sass'])
})
// default
gulp.task('default', ['js', 'sass'])