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

增加支持放置生成的静态资源 (js、css、img、fonts) 的 (相对于 outputDir 的) 目录,就比如vue-cli的额assetDir #4490

Closed
Undefined100 opened this issue Apr 17, 2020 · 10 comments

Comments

@Undefined100
Copy link

Background

为了方便部署

Proposal

增加支持放置生成的静态资源 (js、css、img、fonts) 的 (相对于 outputDir 的) 目录,就比如vue-cli的额assetDir

Additional context

比如生成如下结构:
dist/
index.html
static/
a.js
a.css
......

@zhaoyao91
Copy link

对于非根目录部署,这个非常重要

@aixfox
Copy link
Contributor

aixfox commented May 6, 2020

@zhaoyao91
Copy link

@aixfox 还不是,这里说的是生成的文件中的非 index.html 文件

@aixfox
Copy link
Contributor

aixfox commented May 7, 2020

dist 下是什么样对部署影响不大吧?

vue 的 assetsDir 会传至 file-loader 和 url-loader 的 options.name 和 options.fallback.options.name。
umi 中写死了是 'static',你可以使用 chainWebpack 把配置给改了。

参考:
https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-service/lib/config/base.js#L5
https://github.com/umijs/umi/blob/master/packages/bundler-webpack/src/getConfig/getConfig.ts (搜索 static)

另外,
如果你想改 js 输出路径的话,它们属于 chunk,配置是 webpackConfig.output.filename 和 webpackConfig.output.chunkFilename。

如果你想改 css 输出路径的话,配置是 mini-css-extract-plugin 的 option.filename 和 option.chunkFilename。
参考:
https://github.com/umijs/umi/blob/master/packages/bundler-webpack/src/getConfig/css.ts#L179

@alianggu
Copy link

alianggu commented May 8, 2020

请问这个有解决方案吗

@l-x-f
Copy link

l-x-f commented Jul 22, 2020

针对此问题,我研究了一下,将解决方案整理在下面博客里

https://blog.csdn.net/qq_39953537/article/details/107507724

@wuliupo
Copy link

wuliupo commented May 3, 2022

针对此问题,我研究了一下,将解决方案整理在下面博客里

https://blog.csdn.net/qq_39953537/article/details/107507724

这个配置项太复杂了,太多了。还是希望官方能有一个简单的设置

@lx815
Copy link

lx815 commented Mar 2, 2023

这个配置官方会支持吗?确实自己去配置webpack的话有点麻烦,还是希望官方能给一个简单的设置

@susanred
Copy link

umi4什么时候能出这个配置。上边博客的方法已经失效了

@fz6m
Copy link
Member

fz6m commented Apr 10, 2023

之前也有人提过,但很多地方的路径引用都被写死了,不能自己调整,有 edge case 。

umi 4 应该不会支持自定义产物里分类的目录了。

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

10 participants