dumi icon indicating copy to clipboard operation
dumi copied to clipboard

fix: modify the codesandbox default template and import react

Open 79E opened this issue 1 year ago • 3 comments

🤔 这个变动的性质是?/ What is the nature of this change?

  • [ ] 新特性提交 / New feature
  • [x] bug 修复 / Fix bug
  • [ ] 样式优化 / Style optimization
  • [ ] 代码风格优化 / Code style optimization
  • [ ] 性能优化 / Performance optimization
  • [ ] 构建优化 / Build optimization
  • [ ] 网站、文档、Demo 改进 / Website, documentation, demo improvements
  • [ ] 重构代码或样式 / Refactor code or style
  • [ ] 测试相关 / Test related
  • [ ] 其他 / Other

🔗 相关 Issue / Related Issue

暂无相关issue,操作步骤。

  1. 版本小于 1.1.47
  2. 引入代码块 如果为 .tsx 文件 codesandbox 会识别为 Angular 并且无法加载 .less 样式(看图1图2)
  3. injectReact 方法会给传入文件无论是tsx 还是jsx 还是 less,css都会加上 import React from 'react'; (看图3图4)
image image image image

💡 需求背景和解决方案 / Background or solution

解决方案:

  1. 取消自动导入react包,我认为这是多此一举的操作,用户应该保证它的代码别人复制是可以直接使用。
  2. 将 codesandbox 模版设置为 create-react-app

79E avatar Aug 11 '22 08:08 79E

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated
dumi ⬜️ Ignored (Inspect) Aug 11, 2022 at 8:15AM (UTC)

vercel[bot] avatar Aug 11 '22 08:08 vercel[bot]

⚡️ Deploying PR Preview...

github-actions[bot] avatar Aug 11 '22 08:08 github-actions[bot]

⚡️ Deploying PR Mobile Preview...

github-actions[bot] avatar Aug 11 '22 08:08 github-actions[bot]

如果引用 antd 的 less,就会一直加载中,而其他的 less 就可以(比如 dumi 的)

@import "~antd/dist/antd.less" ❎
@import "dumi-theme-default/es/builtins/Alert.less" ✅

问了一圈,很有可能是 less loader 没有开启 javascriptEnabled

所以目前来看,pro components 还用不了 CRA 的模板.. 只能等 cssinjs 上了才能用

miracles1919 avatar Sep 20 '22 03:09 miracles1919

先合并 #1206 做最小改动了,感谢贡献

PeachScript avatar Sep 28 '22 11:09 PeachScript