| 8 | |
| 9 | describe('custom environment conditions', () => { |
| 10 | function getConfig({ |
| 11 | noExternal, |
| 12 | }: { |
| 13 | noExternal: true | undefined |
| 14 | }): InlineConfig { |
| 15 | return { |
| 16 | configFile: false, |
| 17 | root: import.meta.dirname, |
| 18 | logLevel: 'error', |
| 19 | server: { |
| 20 | middlewareMode: true, |
| 21 | ws: false, |
| 22 | }, |
| 23 | // disable scanner for client env to suppress scanner warnings |
| 24 | optimizeDeps: { entries: [] }, |
| 25 | environments: { |
| 26 | // default |
| 27 | ssr: { |
| 28 | resolve: { |
| 29 | noExternal, |
| 30 | }, |
| 31 | build: { |
| 32 | outDir: path.join( |
| 33 | import.meta.dirname, |
| 34 | 'fixtures/test-dep-conditions/dist/ssr', |
| 35 | ), |
| 36 | rolldownOptions: { |
| 37 | input: { index: '@vitejs/test-dep-conditions' }, |
| 38 | }, |
| 39 | }, |
| 40 | }, |
| 41 | // worker |
| 42 | worker: { |
| 43 | resolve: { |
| 44 | noExternal, |
| 45 | conditions: ['worker'], |
| 46 | externalConditions: ['worker'], |
| 47 | }, |
| 48 | build: { |
| 49 | outDir: path.join( |
| 50 | import.meta.dirname, |
| 51 | 'fixtures/test-dep-conditions/dist/worker', |
| 52 | ), |
| 53 | rolldownOptions: { |
| 54 | input: { index: '@vitejs/test-dep-conditions' }, |
| 55 | }, |
| 56 | }, |
| 57 | }, |
| 58 | // custom1 |
| 59 | custom1: { |
| 60 | resolve: { |
| 61 | noExternal, |
| 62 | conditions: ['custom1'], |
| 63 | externalConditions: ['custom1'], |
| 64 | }, |
| 65 | build: { |
| 66 | outDir: path.join( |
| 67 | import.meta.dirname, |