Skip to content

Fix: Next / Remix adaptation #2754

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: release
Choose a base branch
from

Conversation

anjiazhuyouxing
Copy link
Collaborator

中文模板 / Chinese Template

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Test Case
  • TypeScript definition update
  • Document improve
  • CI/CD improve
  • Branch sync
  • Other, please describe:

PR description

修复Semi在Next/Remix v2的兼容性问题
新增Vite插件

Changelog

🇨🇳 Chinese

  • Fix: 修复Semi在Next/Remix v2的兼容性问题
  • Feat: 新增Vite插件

🇺🇸 English

  • Fix: Fixed the compatibility issue of Semi in Next/Remix v2
  • Feat: Added Vite plugin

Checklist

  • Test or no need
  • Document or no need
  • Changelog or no need

Other

  • Skip Changelog

Additional information

Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 77227f5:

Sandbox Source
pr-story Configuration

@YyumeiZhang YyumeiZhang self-requested a review July 4, 2025 06:31
variables?: { [key: string]: string | number };
include?: string
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SemiThemeOptions 的类型定义很奇怪?和上面的 SemiVitePluginOptions 基本重合了,但是在下面的逻辑中,并没有从 theme 中去取用这些参数




export default function semiVitePlugin(options: SemiVitePluginOptions = {}) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果 export 的是default ,那么在使用文档中就不应该用 import {xxx} 的方式,需要修改下 README.md

t.assignmentExpression(
'=',
t.identifier('lottie'),
t.awaitExpression(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

异步导入,可能会导致使用的时候,lottie 还没有存在

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

用项目测试了下,应为不存在所以导致 Lottie 没有渲染

prefixCls: 'custom'
})
]
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vite 插件中并没有做到替换 prefixCls, prefixCls 的处理分为以下两个部分:

  1. 和scss 文件中的 prefix 前缀相关
    packages/semi-theme-default/scss/variables.scss
  2. 和 tsx 中的样式类名前缀相关
    packages/semi-foundation/base/constants.ts
    packages/semi-icons/src/env.ts
    目前的插件逻辑,没有做这些地方的处理,因此 prefixCls 并不会生效。
    如果暂时不打算处理,则删除下和 prefixCls 相关的说明

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

理应顺便处理一下,对齐 webpack把。

- 完成配置,可以正常使用 Semi 相关组件

**如何在 Remix 中使用主题包**
可以直接将 cssBundleHref 这一步替换为引入主题包中已构建好的全量css 产物,代替默认主题css),例如当希望应用抖音创作服务平台的主题包 `@semi-bot/semi-theme-doucreator` 时
- 首先安装插件 npm i vite-plugin-semi (如果你使用 yarn 或 pnpm,请自行更换为对等命令)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里安装的名称和后面示例中的名称对不上

];
};
/* vite.config.ts */
+ import semi from "vite-plugin-semi-theme";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的导入是否需要修改为新增加的vite 插件?

+ href: ThemeStyle,
},
];
```
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果已经通过插件处理了,为啥这里有需要引入全量的 css,semi.min.css ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants