-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
86 lines (76 loc) · 2.2 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
const gulp = require('gulp');
//const babel = require('gulp-babel');
const concat = require('gulp-concat');
const uglify = require('gulp-uglify-es').default;
const cleanCSS = require('gulp-clean-css');
const purgecss = require('gulp-purgecss')
const postcss = require('gulp-postcss');
const htmlmin = require('gulp-htmlmin');
const del = require('del');
const gulpPostcss = require('gulp-postcss');
const paths = {
root: {
src: './src/index.js',
dest: './dist/'
},
plugin: {
html: {
src: './src/plugin/index.html',
dest: './dist/plugin/'
},
css: {
src: './src/plugin/**/*.css',
dest: './dist/plugin/'
},
js: {
src: './src/plugin/**/*.js',
dest: './dist/plugin/'
}
}
}
function clean() {
return del(['dist']);
}
function root() {
return gulp.src(paths.root.src)
.pipe(uglify())
.pipe(gulp.dest(paths.root.dest))
}
function html() {
return gulp.src(paths.plugin.html.src)
.pipe(htmlmin({ collapseWhitespace: true }))
.pipe(gulp.dest(paths.plugin.html.dest))
}
function css() {
return gulp.src(paths.plugin.css.src)
.pipe(concat({path: 'index.min.css'}))
.pipe(postcss([
require('tailwindcss'),
require('autoprefixer')
]))
.pipe(cleanCSS())
.pipe(purgecss({
content: ['**/*.html']
}))
.pipe(gulp.dest(paths.plugin.css.dest))
}
function js() {
return gulp.src(paths.plugin.js.src)
.pipe(concat({path: 'index.min.js'}))
.pipe(uglify({}))
.pipe(gulp.dest(paths.plugin.js.dest))
}
function watch() {
console.log('Open Feedback: Starting development environment...')
console.log('Open Feedback: Creating initial build...')
build();
console.log('Open Feedback: Watching for changes...')
gulp.watch(paths.plugin.html.src, build);
gulp.watch(paths.plugin.css.src, build);
gulp.watch(paths.plugin.js.src, build);
gulp.watch(paths.root.src, build);
}
const build = gulp.series(clean, gulp.parallel( root, html, css, js));
exports.css = css;
exports.watch = watch;
exports.default = build;