umijs / dumi

📖 Static Site Generator for component library development
https://d.umijs.org
MIT License
3.54k stars 1.17k forks source link

bug: 使用dumi最新版结合landing.ant.design使用 报错 #1581

Closed geekfaith closed 1 year ago

geekfaith commented 1 year ago

Versions

Steps to reproduce

https://landing.ant.design/ 生成的代码,进行引入,我是按照官网教程做的


gapless: true

What is Expected?

能够正常渲染页面

What is actually happening?

启动报错 Webpack resolver error details: resolve '~antd/lib/style/themes/default.less' in '/Users/geek/Software/WebProjects/dumi-demo/docs/Home/less' Parsed request is a module using description file: /Users/geek/Software/WebProjects/dumi-demo/package.json (relative path: ./docs/Home/less) using description file: /Users/geek/Software/WebProjects/dumi-demo/package.json (relative path: ./docs/Home/less/~antd/lib/style/themes/default.less) no extension /Users/geek/Software/WebProjects/dumi-demo/docs/Home/less/~antd/lib/style/themes/default.less doesn't exist .less /Users/geek/Software/WebProjects/dumi-demo/docs/Home/less/~antd/lib/style/themes/default.less.less doesn't exist .css /Users/geek/Software/WebProjects/dumi-demo/docs/Home/less/~antd/lib/style/themes/default.less.css doesn't exist as directory /Users/geek/Software/WebProjects/dumi-demo/docs/Home/less/~antd/lib/style/themes/default.less doesn't exist resolve as module /Users/geek/Software/WebProjects/dumi-demo/docs/Home/less/node_modules doesn't exist or is not a directory /Users/geek/Software/WebProjects/dumi-demo/docs/Home/node_modules doesn't exist or is not a directory /Users/geek/Software/WebProjects/dumi-demo/docs/node_modules doesn't exist or is not a directory looking for modules in /Users/geek/Software/WebProjects/dumi-demo/node_modules /Users/geek/Software/WebProjects/dumi-demo/node_modules/~antd doesn't exist /Users/geek/Software/WebProjects/node_modules doesn't exist or is not a directory /Users/geek/Software/node_modules doesn't exist or is not a directory /Users/geek/node_modules doesn't exist or is not a directory /Users/node_modules doesn't exist or is not a directory /node_modules doesn't exist or is not a directory

Webpack resolver error missing: undefined

  Error in /Users/geek/Software/WebProjects/dumi-demo/docs/Home/less/custom.less (line 1, column 0)

dumi-demo.zip

Wxh16144 commented 1 year ago

看了一下你提供的的 dumi-demo.zip 里面有很多依赖都没添加到依赖项中。可以告知在哪里获取到的压缩包么,不过我建议还是手动安装最新依赖比较好 debug。

geekfaith commented 1 year ago

先找个地方建个空目录。

$ mkdir myapp && cd myapp

通过官方工具创建项目,选择你需要的模板

$ npx create-dumi

安装依赖后启动项目

$ npm start

geekfaith commented 1 year ago

官方脚手架创建的

geekfaith commented 1 year ago

https://landing.ant.design/ 生成的代码,进行引入,Home代码 从这里获取的 这个网站

PeachScript commented 1 year ago

我看 Landing 的官网文档有提到要安装 Landing 组件的依赖,这个是必要的: 图片

Wxh16144 commented 1 year ago

ant-design-landing 一直年久失修的感觉,之前的文档都是基于 dumi1 做,可以先参考 https://github.com/ant-motion/landing-dumi-example 添加对等的依赖,也许这是最快启动项目的方法了

PeachScript commented 1 year ago

另外 dumi 2 的自定义 React 页面可以更加简单了,把 docs/Home/index.jsx 挪到 .dumi/pages/index/index.jsx 即可变成首页,cc @jljsj33 有空更新下用法呗

geekfaith commented 1 year ago

可否出一个2.0的demo给我呀,折腾好久,弄不出来

Wxh16144 commented 1 year ago

可否出一个2.0的demo给我呀,折腾好久,弄不出来

你需要 dumi@2 + antd@4.x 么?我可以去尝试一下 (没接触过,可以给点建议,或者你需要做成什么样?

geekfaith commented 1 year ago

是的,想用 dumi@2 + landing.ant.design 生成的官网代码,这样文档和官网都有了~

geekfaith commented 1 year ago

dumi-demo.zip 这是我配置的,启动会报错

Webpack resolver error details: resolve '~antd/lib/style/index.less' in '/Users/geek/Software/WebProjects/dumi-demo/docs/Home/less' Parsed request is a module using description file: /Users/geek/Software/WebProjects/dumi-demo/package.json (relative path: ./docs/Home/less) using description file: /Users/geek/Software/WebProjects/dumi-demo/package.json (relative path: ./docs/Home/less/~antd/lib/style/index.less) no extension /Users/geek/Software/WebProjects/dumi-demo/docs/Home/less/~antd/lib/style/index.less doesn't exist .less /Users/geek/Software/WebProjects/dumi-demo/docs/Home/less/~antd/lib/style/index.less.less doesn't exist .css /Users/geek/Software/WebProjects/dumi-demo/docs/Home/less/~antd/lib/style/index.less.css doesn't exist as directory /Users/geek/Software/WebProjects/dumi-demo/docs/Home/less/~antd/lib/style/index.less doesn't exist resolve as module /Users/geek/Software/WebProjects/dumi-demo/docs/Home/less/node_modules doesn't exist or is not a directory /Users/geek/Software/WebProjects/dumi-demo/docs/Home/node_modules doesn't exist or is not a directory /Users/geek/Software/WebProjects/dumi-demo/docs/node_modules doesn't exist or is not a directory looking for modules in /Users/geek/Software/WebProjects/dumi-demo/node_modules /Users/geek/Software/WebProjects/dumi-demo/node_modules/~antd doesn't exist /Users/geek/Software/WebProjects/node_modules doesn't exist or is not a directory /Users/geek/Software/node_modules doesn't exist or is not a directory /Users/geek/node_modules doesn't exist or is not a directory /Users/node_modules doesn't exist or is not a directory /node_modules doesn't exist or is not a directory

Wxh16144 commented 1 year ago

dumi-demo-finash.zip

在你提供的基础上我稍微调整了一下, 这个 zip 是可运行的。 我的环境: yarn@1.22.19 + node@16.x + macOS 具体操作步骤在 git log 中,可以打印看一下。

* 8654a41 -  (HEAD -> master) docs: update (7 minutes ago) <wuxh>
* 59bb9fb -  deps: 补充依赖 (13 minutes ago) <wuxh>
* 02ead85 -  Revert "move file" (21 minutes ago) <wuxh>
* 6c629da -  move file (25 minutes ago) <wuxh>
* afaff5e -  deps: antd@4.x (26 minutes ago) <wuxh>
* feaa1ec -  remove .dumi/tmp (30 minutes ago) <wuxh>
* 9b3567e -  deps: upgrade dumi (31 minutes ago) <wuxh>
* 5c6fd4e -  chore: update ignore (33 minutes ago) <wuxh>
* 9bf1e19 -  chore: add packageManage (39 minutes ago) <wuxh>
* c7f4029 -  init (40 minutes ago) <wuxh>
geekfaith commented 1 year ago

![Uploading WeChate55cbc1b4f205b186c6797749b7e01e1.png…]() 样式乱了,1.0的demo 没问题~ 2.0就不行~

Wxh16144 commented 1 year ago

如果没有需要补充的可以 close 咯~

changlin0501 commented 10 months ago

另外 dumi 2 的自定义 React 页面可以更加简单了,把 docs/Home/index.jsx 挪到 .dumi/pages/index/index.jsx 即可变成首页,cc @jljsj33 有空更新下用法呗

请问现在支持自定义首页嘛!使用Ant Design Langding 如何使用

changlin0501 commented 10 months ago

可否出一个2.0的demo给我呀,折腾好久,弄不出来

你好,请问您有成功使用dumi2 +Ant Design Landing 首页搭建出来没

PeachScript commented 10 months ago

dumi 2 支持自定义首页,在 .dumi/pages/index.tsx 里放置自定义 React 组件即可

但 Ant Design Landing 似乎不迭代了,能否正常使用需要参考它的文档进行尝试,把 dumi 1 的部分忽略以上面 dumi 2 的用法为准