From 525155eebc628fbd915d632bdc7f9e851ab6dd02 Mon Sep 17 00:00:00 2001 From: SolitudeRA Date: Wed, 21 Jan 2026 19:37:21 +0900 Subject: [PATCH] chore: update postcss config --- postcss.config.cjs | 3 --- postcss.config.mjs | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) delete mode 100644 postcss.config.cjs create mode 100644 postcss.config.mjs diff --git a/postcss.config.cjs b/postcss.config.cjs deleted file mode 100644 index 0685607..0000000 --- a/postcss.config.cjs +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - plugins: [require('autoprefixer'), require('cssnano')], -}; diff --git a/postcss.config.mjs b/postcss.config.mjs new file mode 100644 index 0000000..7f445f4 --- /dev/null +++ b/postcss.config.mjs @@ -0,0 +1,32 @@ +/** + * PostCSS 配置 + * + * @see https://tailwindcss.com/docs/installation/vite + */ +const isProduction = process.env.NODE_ENV === 'production'; + +export default { + plugins: { + // 自动添加浏览器前缀 + autoprefixer: {}, + + // 仅在生产环境中压缩 CSS + ...(isProduction && { + cssnano: { + preset: [ + 'default', + { + // 移除所有注释 + discardComments: { removeAll: true }, + // 规范化空白 + normalizeWhitespace: true, + // 合并相同规则 + mergeRules: true, + // 移除重复规则 + discardDuplicates: true, + }, + ], + }, + }), + }, +};