Skip to content
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

bug: 非根目录打包后白屏 #1852

Closed
czb128abc opened this issue Aug 23, 2023 · 3 comments
Closed

bug: 非根目录打包后白屏 #1852

czb128abc opened this issue Aug 23, 2023 · 3 comments
Labels
question Further information is requested

Comments

@czb128abc
Copy link

Versions

  • dumi:v2.2.6
  • node:
  • npm:
  • OS:
  • Browser:

Steps to reproduce

配置文件:

import { defineConfig } from 'dumi';

const isProd = process.env.NODE_ENV === 'production';

export default defineConfig({
  mfsu: isProd ? false : {},
  base:isProd ? '/docs-dist' : '/',
  publicPath: isProd ? '/docs-dist/' : '/',
  runtimePublicPath: isProd ? {}: false,
  history: { type: 'hash' },
  cacheDirectoryPath:`./.dumi/${isProd?'tmp-production':'tmp'}-cache`,
  outputPath: 'docs-dist',
  themeConfig: {
    name: 'pro-crud-page',
  },
  devtool: !isProd ? 'cheap-module-source-map' : false,
});

打包后输出html

<!DOCTYPE html><html><head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="/docs-dist/umi.7ab43a5e.css">
</head>
<body>
<div id="root"></div>
<script src="/docs-dist/umi.4025772a.js"></script>

</body></html>
image 打包文件截图 image

What is Expected?

What is actually happening?

@czb128abc czb128abc added the bug Something isn't working label Aug 23, 2023
@czb128abc
Copy link
Author

打包后文件列表如下:

docs-dist/~demos
docs-dist/curd-page
docs-dist/guide
docs-dist/299.3a02b37c.async.js
docs-dist/299.f9797d42.chunk.css
docs-dist/404.html
docs-dist/476.0da23ec7.async.js
docs-dist/607.0e7d3e02.async.js
docs-dist/629.4991cb48.async.js
docs-dist/demos.4dc37f2b.async.js
docs-dist/docs__curd-page__demo.md.16eb4f76.async.js
docs-dist/docs__curd-page__demo.md.778c6473.chunk.css
docs-dist/docs__guide.md.778c6473.chunk.css
docs-dist/docs__guide.md.ce9d060e.async.js
docs-dist/docs__index.md.778c6473.chunk.css
docs-dist/docs__index.md.6950a73c.async.js
docs-dist/dumi__pages__404.0c45fd57.async.js
docs-dist/dumi__pages__404.8b85f2d9.chunk.css
docs-dist/dumi__pages__Demo.455f9dbe.async.js
docs-dist/dumi__pages__Demo.578aa5c0.chunk.css
docs-dist/dumi__theme__ContextWrapper.d3e2dccf.async.js
docs-dist/dumi__theme__layouts__DocLayout.ec323db5.async.js
docs-dist/index.html
docs-dist/umi.7ab43a5e.css
docs-dist/umi.4025772a.js

@czb128abc
Copy link
Author

代码地址:
https://gitee.com/zbchen/pro-crud-page

@PeachScript PeachScript added question Further information is requested and removed bug Something isn't working labels Aug 23, 2023
@PeachScript
Copy link
Member

你配的是 hash 路由,应当使用 /#/{base} 的形式访问而不是 /{base}

另外 dumi 2 对 hash 路由的支持不完整,锚点之类的会跳转异常,建议用默认的 browser 路由

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

No branches or pull requests

2 participants