-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
103 lines (89 loc) · 2.89 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
let gulp = require('gulp');
let concat = require('gulp-concat');
let postcss = require('gulp-postcss');
let autoprefixer = require('gulp-autoprefixer');
let cleancss = require('gulp-clean-css');
let browserSync = require('browser-sync').create();
let cssnext = require("postcss-preset-env")
let uglify = require("gulp-uglify")
let cssnano = require("cssnano")
let /** @type {import("gulp-imagemin")} */ imagemin;
let /** @type {import("imagemin-jpegtran")}*/ imageminJpegtran;
let /** @type {import("imagemin-pngquant")}*/ imageminPngquant;
/**
* @function css()
* @name css
* 1. Idea project үүсэн хавтасны хажууд package.json үүсгэнэ
* 2. npm install хийнэ.
* 3. Сангаа дуудаж оруулахдаа "absolute path" -ыг зааж өгнө
* @function
* */
/**
* @function js()
* @name js
* 1. Idea project үүсэн хавтасны хажууд package.json үүсгэнэ
* 2. npm install хийнэ.
* 3.Сангаа дуудаж оруулахдаа "absolute path" -ыг зааж өгнө
* @function
* */
async function imageminify(){
const imagemini = await import("gulp-imagemin");
const imagePlugins = [
imagemini.svgo({
plugins: [
]
})
]
return gulp.src('images/*')
.pipe(imagemini.default(imagePlugins))
.pipe(gulp.dest('dist/images'))
}
gulp.task("startup", async ()=>{
await startup();
})
function refresh() {
return gulp.src(['css/*.css'])
.pipe(gulp.dest('css'))
.pipe(browserSync.stream());
}
function css() {
return gulp.src([
'node_modules/perfect-scrollbar/css/perfect-scrollbar.css',
'node_modules/swiper/swiper-bundle.css',
'node_modules/@fancyapps/ui/dist/fancybox.css',
'css/*.css',
])
.pipe(cleancss())
.pipe(concat('root.min.css'))
.pipe(browserSync.stream())
.pipe(autoprefixer({cascade: false}))
.pipe(postcss([], [cssnano()]))
.pipe(gulp.dest('dist/css/'));
}
function js() {
return gulp.src([
'node_modules/@fancyapps/ui/dist/fancybox.umd.js',
// 'node_modules/@fancyapps/ui/src/Fancybox/Fancybox.js',
'node_modules/swiper/swiper-bundle.js',
'node_modules/axios/dist/axios.js',
'js/*.js',
])
.pipe(uglify())
.pipe(concat('root.min.js'))
.pipe(gulp.dest('dist/js/'))
}
function serve(){
browserSync.init({
server: ''
});
gulp.watch('*.html').on('change', css, browserSync.reload);
gulp.watch('./css/*.css').on('change', css, browserSync.reload);
gulp.watch('./js/*.js').on('change', css, browserSync.reload);
gulp.watch('./**/**/*').on('change', function () {
console.log("Watch hit");
browserSync.reload();
});
}
gulp.task('default', gulp.series(serve, css, js));
gulp.task('build', gulp.series(css, js));
gulp.task('css', gulp.series(css));