MCPcopy
hub / github.com/vitejs/vite / buildProject

Function buildProject

packages/vite/src/node/__tests__/build.spec.ts:32–65  ·  view source on GitHub ↗
(cssColor: string)

Source from the content-addressed store, hash-verified

30describe('build', () => {
31 test('file hash should change when css changes for dynamic entries', async () => {
32 const buildProject = async (cssColor: string) => {
33 return (await build({
34 root: resolve(dirname, 'packages/build-project'),
35 logLevel: 'silent',
36 build: {
37 write: false,
38 },
39 plugins: [
40 {
41 name: 'test',
42 resolveId(id) {
43 if (
44 id === 'entry.js' ||
45 id === 'subentry.js' ||
46 id === 'foo.css'
47 ) {
48 return '\0' + id
49 }
50 },
51 load(id) {
52 if (id === '\0entry.js') {
53 return `window.addEventListener('click', () => { import('subentry.js') });`
54 }
55 if (id === '\0subentry.js') {
56 return `import 'foo.css'`
57 }
58 if (id === '\0foo.css') {
59 return `.foo { color: ${cssColor} }`
60 }
61 },
62 },
63 ],
64 })) as RolldownOutput
65 }
66 const result = await Promise.all([
67 buildProject('red'),
68 buildProject('blue'),

Callers 1

build.spec.tsFile · 0.70

Calls 2

buildFunction · 0.90
resolveFunction · 0.50

Tested by

no test coverage detected