Replies: 4 comments
-
I found this code in vite, but I don’t know how to overwrite it. Does vite support rollup array type configuration? // build.ts line 564
function createMoveToVendorChunkFn(config: ResolvedConfig): GetManualChunk {
const cache = new Map<string, boolean>()
return (id, { getModuleInfo }) => {
if (
id.includes('node_modules') &&
!isCSSRequest(id) &&
staticImportedByEntry(id, getModuleInfo, cache)
) {
return 'vendor'
}
}
} |
Beta Was this translation helpful? Give feedback.
-
rollup plugin could modify this. export default function esmify(options: esmifyOption): Plugin {
const cache = new Map();
const normalize = (id: string): string => {
if (cache.has(id)) {
return cache.get(id);
}
const parts = id.split("/node_modules/");
const dirPaths = parts[parts.length - 1].split("/");
let n = `npm~${dirPaths[0]}`;
if (dirPaths[0][0] == "@") {
n = `npm~${dirPaths[0]}~${dirPaths[1]}}`;
}
cache.set(id, n);
return n;
};
return {
name: "rollup-plugin-multiple-vendors",
outputOptions(o) {
o.manualChunks = (id: string, api: GetManualChunkApi) => {
if (id.includes("node_modules")) {
return normalize(id);
}
};
return o;
},
};
}
|
Beta Was this translation helpful? Give feedback.
-
I also need exactly this. I have a react app with vitejs as builder with multiple entry points / pages but vite/rollup is generating only one vendor chunk/bundle with the npm packages for all the entry points instead of having one vendor per entry point / page. Ideally it would be better to have one vendor with all shared dependencies across all entry points and then one extra vendor per page / entry point. But none of those things are happening, I have been googling and trying things for hours now and haven't figure it out yet. Please help! |
Beta Was this translation helpful? Give feedback.
-
Bump, I'm interested in this as well as I'm trying to migrate from vue-cli to vite. However I need the following functionality: https://gist.github.com/Akryum/ece2ca512a1f40d70a1d467566783219 Related questions have also been asked here: If someone could help with this issue it would be greatly appreciated. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I created a multi-page vite framework, but after build it with reference to the official case, all pages share a set of vendor files. In fact, the dependencies of different pages are different.
Beta Was this translation helpful? Give feedback.
All reactions