# HowTo: Patch Vite to expose Rollup cache
Goal is to access and use the Rollup cache between builds using Vite `builder.build()`.
## 1. Find and patch the `buildEnvironment` function
(May be in `node_modules/vite/dist/node/chunks/dep-M1IYMR16.js`, or do a search in `node_modules/vite/dist` for `async function buildEnvironment`)
Make the following changes:
```js
async function buildEnvironment(environment, rollupCache /* add this */) {
```
```js
if (rollupCache) { rollupOptions.cache = rollupCache; } // add this
bundle = await rollup(rollupOptions);
```
And replace
```js
return Array.isArray(outputs) ? res : res[0];
```
with
```js
const returnValue = Array.isArray(outputs) ? res : res[0]
returnValue.cache = bundle.cache
return returnValue
```
## 2. Find and patch `ViteBuilder.build`
(May be in `node_modules/vite/dist/node/chunks/dep-M1IYMR16.js`, or do a search in `node_modules/vite/dist` for `return buildEnvironment(environment)`)
Change it to:
```js
async build(environment, rollupCache) {
return buildEnvironment(environment, rollupCache);
}
```
## References
* https://github.com/onejs/one/blob/8b86518b5009d821b95a90276de67f963735b88d/packages/vxrn/src/utils/fork/vite/build.ts
## Notes
```js
const rollupOptions = {
preserveEntrySignatures: ssr ? "allow-extension" : libOptions ? "strict" : false,
cache: rollupCache /* add this */ || options.watch ? undefined : false,
...options.rollupOptions,
```
The above isn’t working, `rollupOptions.cache` still seems to be false at the end. Probably `options.rollupOptions` is overriding it.