76 Star 194 Fork 89

PESCMS/PESCMS Team

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
compress-css.js 1.06 KB
一键复制 编辑 原始数据 按行查看 历史
const CleanCSS = require('clean-css');
const path = require('path');
const fs = require('fs');
// 指定需要压缩的 CSS 文件
const cssFiles = [
path.join(__dirname, 'Public', 'Theme', 'assets', 'css', 'admin.css'),
path.join(__dirname, 'Public', 'Theme', 'assets', 'css', 'app.css'),
];
cssFiles.forEach(filePath => {
const minFilePath = filePath.replace('.css', '.min.css');
fs.readFile(filePath, 'utf8', (err, data) => {
if (err) {
console.error(`Error reading file: ${err.message}`);
return;
}
const output = new CleanCSS().minify(data);
if (output.errors.length > 0) {
console.error(`Error compressing file: ${output.errors.join(', ')}`);
return;
}
fs.writeFile(minFilePath, output.styles, err => {
if (err) {
console.error(`Error writing minified file: ${err.message}`);
return;
}
console.log(`Compressed ${path.basename(filePath)} to ${path.basename(minFilePath)}`);
});
});
});
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/fallBirds/PESCMS-Team.git
[email protected]:fallBirds/PESCMS-Team.git
fallBirds
PESCMS-Team
PESCMS Team
master

搜索帮助