-
-
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
fix(build): respect rollup output.assetFileNames, fix #2944 #4352
Conversation
Co-authored-by: patak <matias.capeletto@gmail.com>
# Conflicts: # packages/vite/src/node/plugins/asset.ts
Thanks for the PR @SegaraRai, it is ok to continue the work of others if it got stale. No problem. We should also move the 233-300 block to a new function at the end of this file, so the main function is easier to follow. And we can replace the naming of vars like |
Thanks for the review. BTW, I think I should write some tests, but I couldn't figure out how to write tests with multiple vite.config.js... |
5808049
to
261913c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you mentioned, beside of missing test, LGTM
6b18769
to
a5f8e85
Compare
There were some tests added here #4122 for plugin-legacy, but I don't think that this is the best way to test it. We now have 404 in that playground for example. IMO we need a better way to add this to the test suite. We could do it in another PR also, maybe changing some of the playgrounds (like the asset one) to use the function type and return different patterns and then check that the files were properly generated? We could also add unit tests for the new |
35c46b2
to
a4efa39
Compare
a4efa39
to
91c11ca
Compare
Thanks. I've added some unit tests. |
👀 Expecting this to be released. Thank you. |
It still does not work when I use the plugin @vitejs/plugin-Legacy. The plugin seems to add an output config, so the output option is an array type, then I always get the defaults value. const output = config.build?.rollupOptions?.output
const assetFileNames =
(output && !Array.isArray(output) ? output.assetFileNames : undefined) ??
// defaults to '<assetsDir>/[name].[hash][extname]'
// slightly different from rollup's one ('assets/[name]-[hash][extname]')
path.posix.join(config.build.assetsDir, '[name].[hash][extname]') |
|
Yes, @JR93 please open a new issue with a minimal reproduction so the logic can be discussed there. Thanks! |
It looks like ViteJS 2.5.0 fixed a compatibility problem with Rollup (probably this: vitejs/vite#4352) wich makes bundle entries to have a correct name, which drastically simplify the process of finding a corresponding transformed modules.
Description
Fixes #2944.
This PR is a continuation of #2957.
I don't know if it's ok to create a continuation of someone's work, so please close this if it is invalid.
Additional context
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).