(
fixtureDir: string,
options?: {
base?: string;
rollupOutput?: {
entryFileNames?: string;
chunkFileNames?: string;
assetFileNames?: string;
};
},
)
| 134 | } |
| 135 | |
| 136 | export async function buildVite( |
| 137 | fixtureDir: string, |
| 138 | options?: { |
| 139 | base?: string; |
| 140 | rollupOutput?: { |
| 141 | entryFileNames?: string; |
| 142 | chunkFileNames?: string; |
| 143 | assetFileNames?: string; |
| 144 | }; |
| 145 | }, |
| 146 | ) { |
| 147 | const tmp = await withTmpDir({ |
| 148 | dir: path.join(import.meta.dirname!, ".."), |
| 149 | prefix: "tmp_vite_", |
| 150 | }); |
| 151 | |
| 152 | const builder = await createBuilder({ |
| 153 | logLevel: "error", |
| 154 | root: fixtureDir, |
| 155 | base: options?.base, |
| 156 | build: { |
| 157 | emptyOutDir: true, |
| 158 | }, |
| 159 | environments: { |
| 160 | ssr: { |
| 161 | build: { |
| 162 | outDir: path.join(tmp.dir, "_fresh", "server"), |
| 163 | rollupOptions: options?.rollupOutput |
| 164 | ? { output: options.rollupOutput } |
| 165 | : undefined, |
| 166 | }, |
| 167 | }, |
| 168 | client: { |
| 169 | build: { |
| 170 | outDir: path.join(tmp.dir, "_fresh", "client"), |
| 171 | }, |
| 172 | }, |
| 173 | }, |
| 174 | }); |
| 175 | await builder.buildApp(); |
| 176 | |
| 177 | return { |
| 178 | tmp: tmp.dir, |
| 179 | async [Symbol.asyncDispose]() { |
| 180 | return await tmp[Symbol.asyncDispose](); |
| 181 | }, |
| 182 | }; |
| 183 | } |
| 184 | |
| 185 | export function usingEnv(name: string, value: string) { |
| 186 | const prev = Deno.env.get(name); |
no test coverage detected