-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
output.assetFileNames does not work when the project use @vitejs/plugin-legacy #4628
Comments
I got the same problem and I found a related issue: #4221 |
I got the same issue, any known workaround for this? |
In fact, the affected output files are static resource files and special So they are behaviors that occur when you set |
yeah,its issue for me, its not plugin-legacy problem,when output is array,it does not work because plugins/assets.ts take a default assetFileName. i think it's bad, can provide a config to set custom asset name when output is array? |
Same issue for me. Has anyone found a workaround for this? |
mark |
i resolve this issue, it can write a plugin to resolve it |
i also want to know how solved it. Can you talk about it? thank's |
can you talk about how to resolve this? tks |
maybe you can use this plugin to edit assets file name export default () => {
let config
return {
apply: 'build',
enforce: 'pre',
configResolved(cf) {
config = cf;
},
async resolveId(id, importer, options) {
if (config.assetsInclude(id)) {
const resolution = await this.resolve(id, importer, { skipSelf: true, ...options });
if (!resolution) return null;
// you can get current asset url
const { id: url } = resolution;
// you can write new url name by return val
return xxxx;
}
return null
},
}
} |
thanks a lot |
Describe the bug
When the project use [email protected] and @vitejs/plugin-legacy, output.assetFileNames does not work, and the polyfills-legacy file is outside the
js
directory. But it works well when remove @vitejs/plugin-legacy.vite.config.js
:Because @vitejs/plugin-legacy will create and add an output configuration
packages/plugin-legacy/index.js#L219
:When rollupOptions.output is an array, it defaults to '<assetsDir>/[name].[hash][extname]'
packages/vite/src/node/plugins/asset.ts#L309
:Reproduction
https://github.com/JR93/vite-asset-filenames-legacy-bug
System Info
Used Package Manager
yarn
Logs
$ vite build vite v2.5.0 building for production... ✓ 27 modules transformed. dist/assets/js/index-legacy-21b357f9.js 2.88 KiB / brotli: 1.27 KiB dist/assets/polyfills-legacy.7969d14b.js 53.90 KiB / brotli: 19.53 KiB dist/assets/js/vendor-legacy-8de15e13.js 127.96 KiB / brotli: 36.34 KiB dist/assets/favicon.17e50649.svg 1.49 KiB dist/assets/logo.ecc203fb.svg 2.61 KiB dist/index.html 1.59 KiB dist/assets/css/index-d93758c6.css 0.77 KiB / brotli: 0.41 KiB dist/assets/js/index-a1c55ec7.js 1.66 KiB / brotli: 0.68 KiB dist/assets/js/vendor-9c242a8b.js 127.61 KiB / brotli: 36.05 KiB
Validations
The text was updated successfully, but these errors were encountered: