chore: 基础优化 (#2927)

* chore: 优化模块入口文件

* style: 优化字体

* build: 优化局部构建流程

* chore: 优化代码格式
This commit is contained in:
贤心
2025-11-14 00:22:15 +08:00
committed by GitHub
parent f48e8870e3
commit 80bb50d2ce
20 changed files with 89 additions and 67 deletions

43
scripts/dev-builder.mjs Normal file
View File

@@ -0,0 +1,43 @@
/**
* 生成开发包
*/
import { spawn } from 'cross-spawn';
const DEST = 'tests/visual/assets/dist'; // 输出目录
const env = { ...process.env, DEST, MODE: 'dev' };
// 执行 postcss 子进程
export const postcss = (args = [], options = {}) => {
args = [
'src/css/index.css',
'-o',
`${DEST}/css/layui.css`,
'--verbose',
].concat(args);
options = {
env,
stdio: 'inherit',
...options,
};
return spawn('postcss', args, options);
};
// 执行 rollup 子进程
export const rollup = (args = [], options = {}) => {
args = ['-c'].concat(args);
options = {
env,
stdio: 'inherit',
...options,
};
return spawn('rollup', args, options);
};
// 是否执行子进程
if (env.RUN) {
postcss();
rollup();
}

View File

@@ -6,9 +6,7 @@
import { spawn } from 'cross-spawn';
import chalk from 'chalk';
const DEST = 'tests/visual/assets/dist'; // 输出目录
const env = { ...process.env, DEST, MODE: 'dev' };
import { rollup, postcss } from './dev-builder.mjs';
// 初始提示信息
console.log(chalk.hex('#16b777').bold('🚀 Starting Layui development mode...'));
@@ -52,20 +50,13 @@ function pipeOutput(child, prefix) {
});
}
// 启动 rollup 和 postcss watcher
const rollup = spawn('rollup', ['-c', '-w'], {
// 启动 postcss 和 rollup watcher
const child_postcss = postcss(['-w'], {
stdio: 'pipe',
});
const child_rollup = rollup(['-w'], {
stdio: 'pipe',
env,
});
const postcss = spawn(
'postcss',
['src/css/index.css', '-o', `${DEST}/css/layui.css`, '-w', '--verbose'],
{
stdio: 'pipe',
env,
},
);
pipeOutput(rollup, 'rollup');
pipeOutput(postcss, 'postcss');
pipeOutput(child_postcss, 'postcss');
pipeOutput(child_rollup, 'rollup');