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

vite 打包之后 动态生成index[x].css 和本地css路径不匹配,导致样式丢失。 #5318

Closed
waittingbar opened this issue May 7, 2022 · 6 comments

Comments

@waittingbar
Copy link

What is the current behavior? 发生了什么?

项目发布到线上后,如果在浏览器上打开项目,在此期间重新发布项目;此时再点击项目中其他菜单,会存在请求不到样式的情况;刷新页面可恢复正常。
目前猜测是由于重新发布后原来引用的index[x].css更名发生了变化,html去资源中找不到需要的样式。

image

What is the expected behavior? 期望的结果是什么?

期望客户如果在使用过程中,如果发布了版本,能继续使用。目前会出现样式错乱问题!

Any additional comments? 相关环境信息?

  • ice.js Version:2.0.0

  • build.json Configuration

  • {
    "vite": {
    "build": {
    "chunkSizeWarningLimit": 500,
    }
    },
    // "publicPath": "/hotata",
    "plugins": [
    [
    "build-plugin-moment-locales",
    {
    "locales": [
    "zh-cn"
    ]
    }
    ],
    [
    "build-plugin-ignore-style",
    {
    "libraryName": "@alifd/next"
    }
    ]
    ],
    "proxy": {
    "/api": {
    "enable": true,
    "target": "http://192.168.7.201"
    "pathRewrite": {
    "^/api": ""
    }
    }
    }
    }

  • Node Version: 14.17.0

  • Platform: windows 11

@usercao
Copy link

usercao commented May 8, 2022

能否提供一个最小可复现代码

@ClarkXia
Copy link
Collaborator

ClarkXia commented May 9, 2022

@waittingbar 参考下 issue #4818 配置下 cssChunkNames

@waittingbar
Copy link
Author

@waittingbar 参考下 issue #4818 配置下 cssChunkNames
您好,这里的 cssChunkNames 配置时指 vite通过配置路由
component: lazy(() => import(/* webpackChunkName: "Menu2" */'@/pages/Menu2')), 就可以了,还是要通过你提供的那个解决方案去实现。

@waittingbar
Copy link
Author

能否提供一个最小可复现代码

就是 issue #4818 里面提到的问题。

@ClarkXia
Copy link
Collaborator

@waittingbar 通过提供的 cssChunkNames 解决

{
  "vite": true,
  "cssChunkNames": "index-main.css"
}

@waittingbar
Copy link
Author

@ClarkXia 目前通过这个方法可以修改入口css名称,实际问题没解决。只能现在通过不使用分包加载css,js避免发布的问题了。非常感谢你的解答。
{ "vite": true, "cssChunkNames": "index-main.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

No branches or pull requests

3 participants