-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
47 lines (43 loc) · 1.47 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
const autoprefixer = require('gulp-autoprefixer')
const gulp = require('gulp')
const rename = require('gulp-rename')
const sass = require('gulp-sass')
const ts = require('gulp-typescript')
const tsProject = ts.createProject('tsconfig.json')
const webpack = require('webpack')
const webpackDevConfig = require('./webpack.config.js')
const webpackProdConfig = require('./webpack.prod.config.js')
const webpackStream = require('webpack-stream')
const config = require('./config')
gulp.task('sass', () => {
return gulp.src(config.SASS_SOURCE_DIR)
.pipe(sass({
outputStyle: 'compressed',
includePaths: [
'./node_modules/'
]
}))
.on('error', sass.logError)
.pipe(rename(function(path) {
path.basename += '.min'
}))
.pipe(autoprefixer())
.pipe(gulp.dest(config.SASS_OUT_DIR))
})
gulp.task('ts-dev', () => {
return gulp.src(config.JS_SOURCE_DIR)
.pipe(webpackStream(webpackDevConfig, webpack))
.pipe(gulp.dest(config.JS_OUT_DIR))
})
gulp.task('ts-prod', () => {
return gulp.src(config.JS_SOURCE_DIR)
.pipe(webpackStream(webpackProdConfig, webpack))
.pipe(gulp.dest(config.JS_OUT_DIR))
})
gulp.task('watch', () => {
gulp.watch(config.SASS_SOURCES, {ignoreInitial: false}, gulp.series('sass'))
gulp.watch(config.JS_SOURCES, {ignoreInitial: false}, gulp.series('ts-dev'))
})
gulp.task('build', gulp.parallel('sass', 'ts-prod'))
gulp.task('grow-build', gulp.parallel('sass', 'ts-prod'))
gulp.task('default', gulp.series('watch'))