-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
assetFileName invalid while use legacy plugin/使用legacy插件后rollup的assetFileNames设置失效 #6923
Comments
Thank you for your kind reply in Chinese. My compatibility needs are similar to yours. I don't even need to be compatible with chrome 66. Can you share your solution? Thank you very much |
try this,it fix my problem,i dont know wheather this can fix you problem, if this work pls let me know tks modernPolyfills: ['the polyfill module you need'], //or u can just set modernPolyfills:true, true to make it universal |
Yes, it also fix my problem,tks |
I think I may have found another solution,line 4543 of the node_modules/vite/dist/chunks/dep-f9d9421a.js (Source file:https://github.com/vitejs/vite/blob/main/packages/vite/src/node/plugins/asset.ts) change reason: Here are some of my test results: |
{
build: {
assetsDir: 'static/js',
rollupOptions: {
output: {
chunkFileNames: 'static/js/[name]-[hash].js',
entryFileNames: 'static/js/[name]-[hash].js',
assetFileNames: 'static/[ext]/[name]-[hash].[ext]',
manualChunks(id) {
if (id.includes('node_modules')) {
return id.toString().split('node_modules/')[1].split('/')[0].toString()
}
},
},
},
},
} maybe helps if you don't need renderLegacyChunks 😀 |
amazing,This should be the best solution, We think the problem is complicated。 |
yeah i try this,that's a clever thoughts,tks |
yeah i think that's the reason cause our problem but i dont understand your solution in this comment like change path__default.posix.join(config.build.assetsDir, '[name].[hash][extname]') to path__default.posix.join(output[1]?.assetFileNames?.split('/')[0]||config.build.assetsDir, '[ext]/[name].[hash][extname]') can u tell me how to do?tks |
这一行代码是vite下面 asset.ts文件filetobuilturl函数中的,修改这一行代码的意图是将vite.config.js中assetfilenames前面的static提取出来,并用它作为输出目录,如果没有配置assetfilenames再使用原来代码中的默认值(assets),这样外面配置的assetfilenames就不会失效,类似于修改vite.config.js中的assetsDir。 |
that make sence , i finally understand this ,Thank you for your kind reply in Chinese |
Closing as it is a duplicate of #4628 |
Describe the bug
while i write vite config' build module include
my outdir file will bundle correct like
dist
-static
--css
--js
--png
and while use legacyPlugin as
legacyPlugin({ targets: ['chrome 52'], additionalLegacyPolyfills: ['regenerator-runtime/runtime'] })
in config's plugin module in same time
my outdir file wile bundle like
dist
-asset
***.png
***.legacy.js
-static
--css
--js
png filepath is not correct like css file and js file,
is this condition correct or i've just wirte wrong code in my file?
简单来说就是使用legacy插件之前,文件打包后的文件按照我的设置 js/css/png或其他格式的资源文件分别都在dist/static下的各自文件类型的文件夹里,使用legacy插件之后,png文件就直接进assets文件夹了,dist/static文件夹下不再有png的文件夹,css/js文件的文件夹还是正常的
Reproduction
https://github.com/shinjie1210/vite-config/settings
System Info
Used Package Manager
npm
Logs
npm i npm run build issue cause's key code is in vite.config.js with notes
Validations
The text was updated successfully, but these errors were encountered: