From 4082d6e4d25c8c440c621b8ccbca029970801ac8 Mon Sep 17 00:00:00 2001 From: WX-DongXing Date: Tue, 14 Jan 2025 21:04:50 +0800 Subject: [PATCH 1/2] feat: add default cssnano preset options in the RN environment --- packages/webpack-plugin/lib/wxss/loader.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/webpack-plugin/lib/wxss/loader.js b/packages/webpack-plugin/lib/wxss/loader.js index 38f063be3e..89758916d9 100644 --- a/packages/webpack-plugin/lib/wxss/loader.js +++ b/packages/webpack-plugin/lib/wxss/loader.js @@ -32,6 +32,13 @@ const { } = require('./utils') const createHelpers = require('../helpers') +const RN_PRESET_OPTIMISATION = { + reduceInitial: false, + normalizeWhitespace: false, + minifyFontValues: false, + convertValues: false +} + module.exports = async function loader (content, map, meta) { const rawOptions = this.getOptions(schema) const plugins = [] @@ -41,6 +48,7 @@ module.exports = async function loader (content, map, meta) { const externals = mpx.externals const root = mpx.projectRoot const sourceMap = mpx.cssSourceMap || false + const isRN = ['ios', 'android'].includes(mpx.mode) let options @@ -152,12 +160,17 @@ module.exports = async function loader (content, map, meta) { if (this.minimize) { const cssnano = require('cssnano') const minimizeOptions = rawOptions.minimize || {} + const presetOptimisation = Object.assign( + {}, + isRN ? RN_PRESET_OPTIMISATION : {}, + minimizeOptions.optimisation + ) let cssnanoConfig = { - preset: ['cssnano-preset-default', minimizeOptions.optimisation || {}] + preset: ['cssnano-preset-default', presetOptimisation] } if (minimizeOptions.advanced) { cssnanoConfig = { - preset: ['cssnano-preset-advanced', minimizeOptions.optimisation || {}] + preset: ['cssnano-preset-advanced', presetOptimisation] } } plugins.push(cssnano(cssnanoConfig)) From 30e0f85e151be899900a05f94d1d941eb6e01173 Mon Sep 17 00:00:00 2001 From: WX-DongXing Date: Wed, 15 Jan 2025 14:30:05 +0800 Subject: [PATCH 2/2] feat: include harmony --- packages/webpack-plugin/lib/wxss/loader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/webpack-plugin/lib/wxss/loader.js b/packages/webpack-plugin/lib/wxss/loader.js index 89758916d9..515f95ca3d 100644 --- a/packages/webpack-plugin/lib/wxss/loader.js +++ b/packages/webpack-plugin/lib/wxss/loader.js @@ -48,7 +48,7 @@ module.exports = async function loader (content, map, meta) { const externals = mpx.externals const root = mpx.projectRoot const sourceMap = mpx.cssSourceMap || false - const isRN = ['ios', 'android'].includes(mpx.mode) + const isRN = ['ios', 'android', 'harmony'].includes(mpx.mode) let options