alibaba / alibaba/ice

ice.config.mts 支持不同环境判断

Open
#5,602 1 comment 0 reactions 1 assignee Claimed by @ClarkXia View on GitHub
discussion v3
Dominant language
TypeScript
Stars
18.6k
Forks
2.1k
PR merge metrics
No merged PRs in 30d

Description

### 方案

对于不同环境下不同的配置目前是通过以下方式支持:

```ts
import { defineConfig } from '@ice/app';

export default defineConfig(() => ({
publicPath: process.env.NODE_ENV === 'production': 'https://alicdn.com' : '/'
}));
```

但除了上述的环境差异外,还存在着 client 端和 server 端配置不一致,以及仅对 client 端生效的场景,期望通过以下方式支持

```ts
import { defineConfig } from '@ice/app';

export default defineConfig(({ command, isServer, commandArgs }) => ({
...
}));
```

根据传入的不同参数执行对应方法

### 待讨论问题

server 端产物理论上从属于 web,在支持小程序和 weex 开发的基础上最多会有四次执行:

- platform: web / isServer: false
- platform: web / isServer: true
- platform: miniapp / isServer: false
- platfrom: weex / isServer: false

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.