|
| 1 | +import { join } from 'node:path'; |
| 2 | +import { buildAndGetResults } from '@e2e/helper'; |
| 3 | +import { expect, test } from 'vitest'; |
| 4 | + |
| 5 | +test('should extract css when set bundle: true', async () => { |
| 6 | + const fixturePath = join(__dirname, 'bundle'); |
| 7 | + const { contents } = await buildAndGetResults(fixturePath, 'css'); |
| 8 | + const esmFiles = Object.keys(contents.esm); |
| 9 | + expect(esmFiles).toMatchInlineSnapshot(` |
| 10 | + [ |
| 11 | + "<ROOT>/cases/style/css/bundle/dist/esm/static/css/index.css", |
| 12 | + ] |
| 13 | + `); |
| 14 | + |
| 15 | + const cjsFiles = Object.keys(contents.cjs); |
| 16 | + expect(cjsFiles).toMatchInlineSnapshot(` |
| 17 | + [ |
| 18 | + "<ROOT>/cases/style/css/bundle/dist/cjs/static/css/index.css", |
| 19 | + ] |
| 20 | + `); |
| 21 | +}); |
| 22 | + |
| 23 | +test('should extract css when set bundle: false', async () => { |
| 24 | + const fixturePath = join(__dirname, 'bundle-false'); |
| 25 | + const { contents } = await buildAndGetResults(fixturePath, 'css'); |
| 26 | + const esmFiles = Object.keys(contents.esm); |
| 27 | + |
| 28 | + expect(esmFiles).toMatchInlineSnapshot(` |
| 29 | + [ |
| 30 | + "<ROOT>/cases/style/css/bundle-false/dist/esm/import.css", |
| 31 | + "<ROOT>/cases/style/css/bundle-false/dist/esm/lib1.css", |
| 32 | + "<ROOT>/cases/style/css/bundle-false/dist/esm/lib2.css", |
| 33 | + ] |
| 34 | + `); |
| 35 | + |
| 36 | + const cjsFiles = Object.keys(contents.cjs); |
| 37 | + expect(cjsFiles).toMatchInlineSnapshot(` |
| 38 | + [ |
| 39 | + "<ROOT>/cases/style/css/bundle-false/dist/cjs/import.css", |
| 40 | + "<ROOT>/cases/style/css/bundle-false/dist/cjs/lib1.css", |
| 41 | + "<ROOT>/cases/style/css/bundle-false/dist/cjs/lib2.css", |
| 42 | + ] |
| 43 | + `); |
| 44 | +}); |
0 commit comments