-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
75 lines (71 loc) · 1.71 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
const gulp = require('gulp');
const scss = require('gulp-dart-scss');
const autoprefixer = require('gulp-autoprefixer');
const cleanCSS = require('gulp-clean-css');
const browserify = require('browserify');
const tsify = require('tsify');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const sourcemaps = require('gulp-sourcemaps');
const uglify = require('gulp-uglify-es').default;
gulp.task('scss-dirty', function () {
return gulp
.src('./modules/app.scss')
.pipe(scss({ includePaths: ['node_modules'] }))
.pipe(autoprefixer('last 5 version'))
.pipe(gulp.dest('/'));
});
gulp.task('scss-clean', function () {
return gulp
.src('./modules/app.scss')
.pipe(scss({ includePaths: ['node_modules'] }))
.pipe(autoprefixer('last 5 version'))
.pipe(
cleanCSS({
rebase: false,
level: {
1: {
specialComments: 0,
},
2: {
restructureRules: true,
mergeSemantically: true,
},
},
})
)
.pipe(gulp.dest('/'));
});
gulp.task('ts', function () {
return browserify({
entries: './modules/app.ts',
extensions: ['.ts'],
debug: true,
})
.plugin(tsify)
.transform('babelify', {
presets: ['@babel/env', '@babel/preset-typescript'],
plugins: [
[
'@babel/plugin-transform-runtime',
{
corejs: '3',
},
],
],
extensions: ['.ts'],
sourceMaps: true,
global: true,
})
.bundle()
.pipe(source('app.js'))
.pipe(buffer())
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(uglify())
.pipe(sourcemaps.write('/'))
.pipe(gulp.dest('/'));
});
gulp.task('watch', function () {
gulp.watch('./modules/**/*.scss', gulp.series('scss-dirty'));
gulp.watch('./modules/**/*.ts', gulp.series('ts'));
});