-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.mjs
54 lines (45 loc) · 1.43 KB
/
gulpfile.mjs
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
import fs from 'node:fs';
import uglifyEs from 'uglify-es';
import gulp from 'gulp';
import replace from 'gulp-replace';
import header from 'gulp-header';
import rename from 'gulp-rename';
import { deleteAsync, deleteSync } from 'del';
import composer from 'gulp-uglify/composer.js';
import babel from 'gulp-babel';
import postcss from 'gulp-postcss';
import postcssNested from 'postcss-nested';
import autoprefixer from 'autoprefixer';
import cssnano from 'cssnano';
const { series, parallel, src, dest, task } = gulp;
const uglify = composer(uglifyEs, console);
task('clean', () => {
return deleteAsync('www/assets/**/*.min.*');
})
task('minifyCSS', () => {
const plugins = [
autoprefixer(),
postcssNested(),
cssnano()
]
return src('www/assets/css/**.css')
.pipe(postcss(plugins))
.pipe(header('/* minified */\n'))
.pipe(rename({ extname: '.min.css' }))
.pipe(dest('www/assets/css/'));
});
task('minifyJS', () => {
return src('www/assets/js/**.js')
.pipe(babel({
presets: ['@babel/env']
}))
.pipe(uglify({
output: {
beautify: false,
preamble: "/* uglified */"
}
}))
.pipe(rename({ extname: '.min.js' }))
.pipe(dest('www/assets/js/'));
});
task('default', series('clean', parallel('minifyCSS', 'minifyJS')));