2022-09-01 02:15:45 +08:00
|
|
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under MIT */
|
2019-06-29 22:16:09 +08:00
|
|
|
const gulp = require('gulp');
|
|
|
|
|
2021-07-21 17:20:55 +08:00
|
|
|
const concat = require('gulp-concat');
|
2019-07-05 03:09:27 +08:00
|
|
|
const rename = require('gulp-rename');
|
|
|
|
const replace = require('gulp-replace');
|
|
|
|
const eol = require('gulp-eol');
|
|
|
|
const filter = require('gulp-filter');
|
|
|
|
const expect = require('gulp-expect-file');
|
2021-07-20 22:45:55 +08:00
|
|
|
const gcmq = require('gulp-group-css-media-queries');
|
2023-02-24 19:27:50 +08:00
|
|
|
const less = require('gulp-less');
|
2019-06-29 22:16:09 +08:00
|
|
|
|
2019-07-05 03:09:27 +08:00
|
|
|
const { config } = require('./config');
|
|
|
|
const { del } = require('./common');
|
2019-06-29 22:16:09 +08:00
|
|
|
|
2021-02-05 17:42:20 +08:00
|
|
|
const cleanCss = require('gulp-clean-css');
|
2019-06-29 22:16:09 +08:00
|
|
|
const cssClean = () => del(config.paths.staticCSS + '/*.css');
|
|
|
|
|
2020-09-05 18:22:46 +08:00
|
|
|
const cssBootBuild = () => {
|
2021-02-04 22:03:11 +08:00
|
|
|
const
|
2020-09-05 18:22:46 +08:00
|
|
|
src = config.paths.css.boot.src;
|
|
|
|
return gulp
|
|
|
|
.src(src)
|
|
|
|
.pipe(expect.real({ errorOnFailure: true }, src))
|
|
|
|
.pipe(concat(config.paths.css.boot.name))
|
|
|
|
.pipe(replace(/\.\.\/(img|images|fonts|svg)\//g, '$1/'))
|
|
|
|
.pipe(eol('\n', true))
|
|
|
|
.pipe(gulp.dest(config.paths.staticCSS));
|
|
|
|
};
|
|
|
|
|
2019-06-29 22:16:09 +08:00
|
|
|
const cssMainBuild = () => {
|
2021-02-04 22:03:11 +08:00
|
|
|
const
|
2019-07-05 03:09:27 +08:00
|
|
|
lessFilter = filter('**/*.less', { restore: true }),
|
2019-06-29 22:16:09 +08:00
|
|
|
src = config.paths.css.main.src.concat([config.paths.less.main.src]);
|
|
|
|
|
2019-07-05 03:09:27 +08:00
|
|
|
return gulp
|
|
|
|
.src(src)
|
|
|
|
.pipe(expect.real({ errorOnFailure: true }, src))
|
2019-06-29 22:16:09 +08:00
|
|
|
.pipe(lessFilter)
|
2019-07-05 03:09:27 +08:00
|
|
|
.pipe(
|
|
|
|
less({
|
|
|
|
'paths': config.paths.less.main.options.paths
|
|
|
|
})
|
|
|
|
)
|
2019-06-29 22:16:09 +08:00
|
|
|
.pipe(lessFilter.restore)
|
|
|
|
.pipe(concat(config.paths.css.main.name))
|
|
|
|
.pipe(replace(/\.\.\/(img|images|fonts|svg)\//g, '$1/'))
|
|
|
|
.pipe(eol('\n', true))
|
2021-07-21 17:20:55 +08:00
|
|
|
.pipe(gulp.dest(config.paths.staticCSS));
|
2019-06-29 22:16:09 +08:00
|
|
|
};
|
|
|
|
|
2021-02-19 04:06:19 +08:00
|
|
|
const cssAdminBuild = () => {
|
|
|
|
const
|
|
|
|
lessFilter = filter('**/*.less', { restore: true }),
|
2021-11-16 19:35:11 +08:00
|
|
|
src = config.paths.css.admin.src;
|
2021-02-19 04:06:19 +08:00
|
|
|
|
|
|
|
return gulp
|
|
|
|
.src(src)
|
|
|
|
.pipe(expect.real({ errorOnFailure: true }, src))
|
|
|
|
.pipe(lessFilter)
|
|
|
|
.pipe(
|
|
|
|
less({
|
|
|
|
'paths': config.paths.less.main.options.paths
|
|
|
|
})
|
|
|
|
)
|
|
|
|
.pipe(lessFilter.restore)
|
|
|
|
.pipe(concat(config.paths.css.admin.name))
|
|
|
|
.pipe(replace(/\.\.\/(img|images|fonts|svg)\//g, '$1/'))
|
|
|
|
.pipe(eol('\n', true))
|
2021-07-21 17:20:55 +08:00
|
|
|
.pipe(gulp.dest(config.paths.staticCSS));
|
2021-02-19 04:06:19 +08:00
|
|
|
};
|
|
|
|
|
2020-09-05 18:22:46 +08:00
|
|
|
const cssBootMin = () => {
|
|
|
|
return gulp
|
|
|
|
.src(config.paths.staticCSS + config.paths.css.boot.name)
|
|
|
|
.pipe(cleanCss())
|
|
|
|
.pipe(rename({ suffix: '.min' }))
|
|
|
|
.pipe(eol('\n', true))
|
|
|
|
.pipe(gulp.dest(config.paths.staticCSS));
|
|
|
|
};
|
|
|
|
|
2019-06-29 22:16:09 +08:00
|
|
|
const cssMainMin = () => {
|
2019-07-05 03:09:27 +08:00
|
|
|
return gulp
|
|
|
|
.src(config.paths.staticCSS + config.paths.css.main.name)
|
2021-07-20 22:45:55 +08:00
|
|
|
.pipe(gcmq())
|
2019-06-29 22:16:09 +08:00
|
|
|
.pipe(cleanCss())
|
2019-07-05 03:09:27 +08:00
|
|
|
.pipe(rename({ suffix: '.min' }))
|
2019-06-29 22:16:09 +08:00
|
|
|
.pipe(eol('\n', true))
|
|
|
|
.pipe(gulp.dest(config.paths.staticCSS));
|
|
|
|
};
|
|
|
|
|
2021-02-19 04:06:19 +08:00
|
|
|
const cssAdminMin = () => {
|
|
|
|
return gulp
|
|
|
|
.src(config.paths.staticCSS + config.paths.css.admin.name)
|
2021-07-20 22:45:55 +08:00
|
|
|
.pipe(gcmq())
|
2021-02-19 04:06:19 +08:00
|
|
|
.pipe(cleanCss())
|
|
|
|
.pipe(rename({ suffix: '.min' }))
|
|
|
|
.pipe(eol('\n', true))
|
|
|
|
.pipe(gulp.dest(config.paths.staticCSS));
|
|
|
|
};
|
|
|
|
|
|
|
|
const cssBuild = gulp.parallel(cssBootBuild, cssMainBuild, cssAdminBuild);
|
|
|
|
const cssMin = gulp.parallel(cssBootMin, cssMainMin, cssAdminMin);
|
2019-06-29 22:16:09 +08:00
|
|
|
|
|
|
|
const cssLint = (done) => done();
|
|
|
|
|
|
|
|
const cssState1 = gulp.series(cssLint);
|
|
|
|
const cssState2 = gulp.series(cssClean, cssBuild, cssMin);
|
|
|
|
|
|
|
|
exports.cssLint = cssLint;
|
|
|
|
exports.cssBuild = cssBuild;
|
|
|
|
|
|
|
|
exports.css = gulp.parallel(cssState1, cssState2);
|