umijs / dumi

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

bug: 打包后部署,样式全部失效 #2202

Closed wchbrad closed 2 months ago

wchbrad commented 2 months ago

Version

2.4.9

OS Version

windows 11

Node.js Version

20.17.0

Browser Version

chrome 128.0.6613.138(正式版本) (64 位)

Link to minimal reproduction

使用官方脚手架npx create-dumi初始化

Steps to reproduce

使用官方脚手架初始化成功

npx create-dumi
Need to install the following packages:
create-dumi@2.3.1
Ok to proceed? (y) y

√ Pick template type » React Library
√ Pick NPM client » pnpm
√ Input NPM package name ... ac
√ Input project description ... A react library developed with dumi
√ Input project author (Name <email@example.com>) ...
Write: .dumirc.ts
Copy:  .editorconfig
Copy:  .eslintrc.js
Copy:  .fatherrc.ts
Write: .gitignore
Copy:  .husky/commit-msg
Copy:  .husky/pre-commit
Copy:  .prettierignore
Copy:  .prettierrc.js
Copy:  .stylelintrc
Copy:  docs/guide.md
Write: docs\index.md
Write: LICENSE
Write: package.json
Write: README.md
Write: src\Foo\index.md
Copy:  src/Foo/index.tsx
Copy:  src/index.ts
Write: tsconfig.json
Downloading typescript@5.3.3: 5.76 MB/5.76 MB, done
Downloading @swc/core-win32-x64-msvc@1.4.2: 16.52 MB/16.52 MB, done
Downloading @formatjs/intl-displaynames@6.6.8: 6.00 MB/6.00 MB, done
Downloading @umijs/mako-win32-x64-msvc@0.8.11: 16.33 MB/16.33 MB, done
 WARN  19 deprecated subdependencies found: @floating-ui/react-dom-interactions@0.3.1, @humanwhocodes/config-array@0.13.0, @humanwhocodes/object-schema@2.0.3, @stylelint/postcss-css-in-js@0.38.0, axios@0.18.1, copy-concurrently@1.0.5, fs-write-stream-atomic@1.0.10, glob@7.2.3, inflight@1.0.6, move-concurrently@1.0.1, node-fetch-npm@2.0.4, osenv@0.1.5, q@1.5.1, rimraf@2.7.1, rimraf@3.0.2, shortid@2.2.16, socks@1.1.10, source-map-resolve@0.6.0, stable@0.1.8
Packages: +1619
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 1718, reused 0, downloaded 1620, added 1619, done
node_modules/.pnpm/core-js@3.34.0/node_modules/core-js: Running postinstall script, done in 188ms
node_modules/.pnpm/core-js-pure@3.38.1/node_modules/core-js-pure: Running postinstall script, done in 189ms
node_modules/.pnpm/@swc+core@1.4.2_@swc+helpers@0.5.1/node_modules/@swc/core: Running postinstall script, done in 180ms
node_modules/.pnpm/esbuild@0.21.4/node_modules/esbuild: Running postinstall script, done in 1.6s
node_modules/.pnpm/esbuild@0.18.20/node_modules/esbuild: Running postinstall script, done in 1.5s
node_modules/.pnpm/esbuild@0.17.19/node_modules/esbuild: Running postinstall script, done in 1.3s

> ac@0.0.1 prepare D:\demo
> husky install && dumi setup

fatal: not a git repository (or any of the parent directories): .git
husky - git command not found, skipping install
info  - dumi v2.4.11
info  - generate files

devDependencies:
+ @commitlint/cli 17.8.1 (19.5.0 is available)
+ @commitlint/config-conventional 17.8.1 (19.5.0 is available)
+ @types/react 18.3.7
+ @types/react-dom 18.3.0
+ @umijs/lint 4.3.20
+ dumi 2.4.11
+ eslint 8.57.1 (9.10.0 is available)
+ father 4.5.0
+ husky 8.0.3 (9.1.6 is available)
+ lint-staged 13.3.0 (15.2.10 is available)
+ prettier 2.8.8 (3.3.3 is available)
+ prettier-plugin-organize-imports 3.2.4 (4.0.0 is available)
+ prettier-plugin-packagejson 2.5.2
+ react 18.3.1
+ react-dom 18.3.1
+ stylelint 14.16.1 (16.9.0 is available)

Done in 1m 26.2s

然后打包文档

pnpm docs:build

> ac@0.0.1 docs:build D:\demo
> dumi build

info  - dumi v2.4.11
info  - Umi v4.3.20

√ Webpack
  Compiled successfully in 10.10s

info  - Memory Usage: 462.06 MB (RSS: 590.62 MB)

● Webpack █████████████████████████ cache (99%)
 shutdown

info  - File sizes after gzip:

  302.82 kB  docs-dist\umi.b156075b.js
  62.91 kB   docs-dist\145.75ea0e35.async.js
  39.29 kB   docs-dist\717.e8c51481.chunk.css
  29.88 kB   docs-dist\717.9cf77e61.async.js
  22.6 kB    docs-dist\27.8e02c3a2.async.js
  6.24 kB    docs-dist\umi.b7ce68f4.css
  820 B      docs-dist\dumi__tmp-production__dumi__theme__ContextWrapper.9c96dbec.async.js
  775 B      docs-dist\meta__Foo.abd97ca4.async.js
  492 B      docs-dist\nm__dumi__dist__client__pages__Demo__index.ff8aa483.async.js
  467 B      docs-dist\Foo__index.md.75021826.async.js
  350 B      docs-dist\docs__guide.md.3b53c5ca.async.js
  349 B      docs-dist\docs__index.md.224d0348.async.js
  319 B      docs-dist\nm__dumi__theme-default__layouts__DocLayout__index.b114e3d8.async.js
  307 B      docs-dist\nm__dumi__dist__client__pages__404.802aac62.async.js
  277 B      docs-dist\nm__dumi__dist__client__pages__404.8b85f2d9.chunk.css
  249 B      docs-dist\meta__docs.f50542a9.async.js
  45 B       docs-dist\nm__dumi__dist__client__pages__Demo__index.578aa5c0.chunk.css

event - Build 404.html
event - Build guide\index.html
event - Build index.html
event - Build components\foo\index.html
event - Build ~demos/foo-demo-0/index.html

部署到nginx上,打开页面,页面未报错,但是所有的样式失效了 image

请问是怎么回事

What is expected?

文档样式正常显示,与开发环境一致

What is actually happening?

文档样式全部失效 image

Any additional comments? (optional)

No response

wchbrad commented 2 months ago

已解决