Compare commits

...

7 Commits

Author SHA1 Message Date
ZeroLing cf3bb16c44
Merge f5005afad5 into ace5e1dd15 2025-07-24 16:30:06 +08:00
ClarkXia ace5e1dd15
Merge pull request #7127 from alibaba/hotfix/env
CI / build (16.x, ubuntu-latest) (push) Has been cancelled Details
CI / build (16.x, windows-latest) (push) Has been cancelled Details
CI / build (18.x, ubuntu-latest) (push) Has been cancelled Details
CI / build (18.x, windows-latest) (push) Has been cancelled Details
Coverage / coverage (16.x) (push) Has been cancelled Details
Release / Release (16) (push) Has been cancelled Details
hotfix: add isPHA and isKraken env for backward compatibility
2025-07-24 15:27:08 +08:00
zhuoling.lcl f5005afad5 chore: delete 2 useless files
CI / build (16.x, ubuntu-latest) (push) Has been cancelled Details
CI / build (16.x, windows-latest) (push) Has been cancelled Details
CI / build (18.x, ubuntu-latest) (push) Has been cancelled Details
CI / build (18.x, windows-latest) (push) Has been cancelled Details
2025-07-16 10:33:27 +08:00
zhuoling.lcl 2c40f39fff fix: remove useless files 2025-07-16 10:15:16 +08:00
zhuoling.lcl 837946a37f fix: css in ~ 2025-07-16 10:12:06 +08:00
zhuoling.lcl 41cbaa9cd1 chore: add changeset 2025-07-15 19:54:01 +08:00
zhuoling.lcl 637f24a10a fix: rax compat support ~ in css 2025-07-15 19:52:44 +08:00
7 changed files with 66 additions and 3 deletions

View File

@ -0,0 +1,5 @@
---
'@ice/plugin-rax-compat': patch
---
Support css build

View File

@ -1,5 +1,9 @@
# Changelog
## 3.6.5
- hotfix: add isPHA and isKraken env for backward compatibility.
## 3.6.4
### Patch Changes

View File

@ -1,6 +1,6 @@
{
"name": "@ice/app",
"version": "3.6.4",
"version": "3.6.5",
"description": "provide scripts and configuration used by web framework ice",
"type": "module",
"main": "./esm/index.js",

View File

@ -11,9 +11,11 @@ export const isKuaiShouMiniProgram = isClient && import.meta.target === 'kuaisho
export const isWeChatMiniProgram = isClient && import.meta.target === 'wechat-miniprogram';
export const isQuickApp = false; // Now ice.js will not implement quick app target.
export const isMiniApp = isAliMiniApp; // in universal-env, isMiniApp is equals to isAliMiniApp
export const isKraken = isClient && import.meta.target === 'kraken';
// Following variables are runtime executed envs.
// See also @uni/env.
export const isPHA = isWeb && typeof pha === 'object';
const ua = typeof navigator === 'object' ? navigator.userAgent || navigator.swuserAgent : '';
export const isThemis = /Themis/.test(ua);
export const isWindVane = /WindVane/i.test(ua) && isWeb && typeof WindVane !== 'undefined' && typeof WindVane.call !== 'undefined';
@ -25,6 +27,8 @@ export default {
isWeb,
isNode,
isWeex,
isKraken,
isPHA,
isThemis,
isMiniApp,
isByteDanceMicroApp,

View File

@ -0,0 +1,23 @@
/* 示例CSS 中使用波浪号导入语法 */
/* 导入第三方包的样式 */
@import "~@ali/fusion-design/theme.css";
@import "~antd/dist/antd.css";
/* 导入内部包的样式 */
@import "~@company/design-system/tokens.css";
@import '~@internal/shared-styles/base.css';
/* 常规导入(不受影响) */
@import "./local-styles.css";
@import url("https://cdn.example.com/remote.css");
/* 组件样式 */
.example-component {
color: var(--primary-color);
font-size: 16px;
}
.example-component:hover {
color: var(--primary-hover-color);
}

View File

@ -25,9 +25,11 @@ const transformer = transformerModule.default;
async function styleSheetLoader(source: string, sourcePath: string, type: StyleKind = 'css') {
let cssContent = source;
// Transform @import "~..." to @import "..." for all style types
cssContent = cssContent.replace(/@import\s+(['"])~([^'"]+)\1/g, '@import $1$2$1');
if (type === 'less') {
// compact for @import "~bootstrap/less/bootstrap";
cssContent = cssContent.replace(/@import "~/g, '@import "');
cssContent = (
await less.render(cssContent, {
// For relative @import path

View File

@ -1,4 +1,5 @@
import fs from 'fs';
import { createRequire } from 'module';
import styleSheetLoader from '../../lib/transform-styles.js';
@ -6,10 +7,34 @@ import { checkInlineStyleEnable, checkStyleKind } from '../../utils.js';
import type { ESBuildPlugin, NormalizedRaxCompatPluginOptions, PluginAPI } from '../../typings';
const ESBuildInlineStylePlugin = (options: NormalizedRaxCompatPluginOptions): ESBuildPlugin => {
return {
name: 'esbuild-inline-style',
setup: (build) => {
build.onResolve({ filter: /\.(css|sass|scss|less)$/ }, async (args) => {
if (args.path.startsWith('~')) {
const cleanPath = args.path.slice(1);
try {
// Try to resolve as absolute path
const require = createRequire(args.importer || import.meta.url);
const resolvedPath = require.resolve(cleanPath);
return {
path: resolvedPath,
namespace: args.namespace,
};
} catch (resolveError) {
// If unable to resolve, mark as external dependency
return {
path: cleanPath,
external: true,
};
}
}
return null;
});
build.onLoad({ filter: /\.(css|sass|scss|less)$/ }, async (args) => {
if (checkInlineStyleEnable(args.path, options.inlineStyle) === false) {
return null;