mirror of
https://github.com/element-plus/element-plus.git
synced 2024-12-21 02:50:11 +08:00
bb939c6a58
* refactor(build): move to internal package * ci: fix * chore: fix * fix: docs * chore: add fast-glob to root package * chore: fix PR comments * build: add tsx * refactor: re-organize * refactor: improve log
68 lines
1.7 KiB
TypeScript
68 lines
1.7 KiB
TypeScript
import path from 'path'
|
|
import chalk from 'chalk'
|
|
import { src, dest, series, parallel } from 'gulp'
|
|
import gulpSass from 'gulp-sass'
|
|
import dartSass from 'sass'
|
|
import autoprefixer from 'gulp-autoprefixer'
|
|
import cleanCSS from 'gulp-clean-css'
|
|
import rename from 'gulp-rename'
|
|
import consola from 'consola'
|
|
import { epOutput } from '@element-plus/build'
|
|
|
|
const distFolder = path.resolve(__dirname, 'dist')
|
|
const distBundle = path.resolve(epOutput, 'theme-chalk')
|
|
|
|
/**
|
|
* compile theme-chalk scss & minify
|
|
* not use sass.sync().on('error', sass.logError) to throw exception
|
|
* @returns
|
|
*/
|
|
function buildThemeChalk() {
|
|
const sass = gulpSass(dartSass)
|
|
const noElPrefixFile = /(index|base|display)/
|
|
return src(path.resolve(__dirname, 'src/*.scss'))
|
|
.pipe(sass.sync())
|
|
.pipe(autoprefixer({ cascade: false }))
|
|
.pipe(
|
|
cleanCSS({}, (details) => {
|
|
consola.success(
|
|
`${chalk.cyan(details.name)}: ${chalk.yellow(
|
|
details.stats.originalSize / 1000
|
|
)} KB -> ${chalk.green(details.stats.minifiedSize / 1000)} KB`
|
|
)
|
|
})
|
|
)
|
|
.pipe(
|
|
rename((path) => {
|
|
if (!noElPrefixFile.test(path.basename)) {
|
|
path.basename = `el-${path.basename}`
|
|
}
|
|
})
|
|
)
|
|
.pipe(dest(distFolder))
|
|
}
|
|
|
|
/**
|
|
* copy from packages/theme-chalk/dist to dist/element-plus/theme-chalk
|
|
*/
|
|
export function copyThemeChalkBundle() {
|
|
return src(`${distFolder}/**`).pipe(dest(distBundle))
|
|
}
|
|
|
|
/**
|
|
* copy source file to packages
|
|
*/
|
|
|
|
export function copyThemeChalkSource() {
|
|
return src(path.resolve(__dirname, 'src/**')).pipe(
|
|
dest(path.resolve(distBundle, 'src'))
|
|
)
|
|
}
|
|
|
|
export const build = parallel(
|
|
copyThemeChalkSource,
|
|
series(buildThemeChalk, copyThemeChalkBundle)
|
|
)
|
|
|
|
export default build
|