mirror of
https://github.com/vitejs/vite.git
synced 2024-11-21 22:59:10 +00:00
test(css): deterministic css emit with the same file basename (#12773)
This commit is contained in:
parent
f09551f18d
commit
b91135c009
@ -0,0 +1,19 @@
|
||||
import { beforeEach, describe, expect, test } from 'vitest'
|
||||
import { findAssetFile, isBuild, startDefaultServe } from '~utils'
|
||||
|
||||
beforeEach(async () => {
|
||||
await startDefaultServe()
|
||||
})
|
||||
|
||||
for (let i = 0; i < 5; i++) {
|
||||
describe.runIf(isBuild)('css files has same basename', () => {
|
||||
test('emit file name should consistent', () => {
|
||||
expect(findAssetFile('sub.css', 'same-file-name', '.')).toMatch(
|
||||
'.sub1-sub',
|
||||
)
|
||||
expect(findAssetFile('sub2.css', 'same-file-name', '.')).toMatch(
|
||||
'.sub2-sub',
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
2
playground/css/__tests__/same-file-name/vite.config.js
Normal file
2
playground/css/__tests__/same-file-name/vite.config.js
Normal file
@ -0,0 +1,2 @@
|
||||
import config from '../../vite.config-same-file-name'
|
||||
export default config
|
@ -117,3 +117,6 @@ document
|
||||
import './unsupported.css'
|
||||
|
||||
import './async/index'
|
||||
|
||||
import('./same-name/sub1/sub')
|
||||
import('./same-name/sub2/sub')
|
||||
|
3
playground/css/same-name/sub1/sub.css
Normal file
3
playground/css/same-name/sub1/sub.css
Normal file
@ -0,0 +1,3 @@
|
||||
.sub1-sub {
|
||||
color: red;
|
||||
}
|
3
playground/css/same-name/sub1/sub.js
Normal file
3
playground/css/same-name/sub1/sub.js
Normal file
@ -0,0 +1,3 @@
|
||||
import './sub.css'
|
||||
|
||||
export default 'sub1-name'
|
3
playground/css/same-name/sub2/sub.css
Normal file
3
playground/css/same-name/sub2/sub.css
Normal file
@ -0,0 +1,3 @@
|
||||
.sub2-sub {
|
||||
color: blue;
|
||||
}
|
3
playground/css/same-name/sub2/sub.js
Normal file
3
playground/css/same-name/sub2/sub.js
Normal file
@ -0,0 +1,3 @@
|
||||
import './sub.css'
|
||||
|
||||
export default 'sub2-name'
|
17
playground/css/vite.config-same-file-name.js
Normal file
17
playground/css/vite.config-same-file-name.js
Normal file
@ -0,0 +1,17 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import baseConfig from './vite.config.js'
|
||||
|
||||
export default defineConfig({
|
||||
...baseConfig,
|
||||
build: {
|
||||
...baseConfig.build,
|
||||
outDir: 'dist/same-file-name',
|
||||
rollupOptions: {
|
||||
output: {
|
||||
entryFileNames: '[name].js',
|
||||
chunkFileNames: '[name].[hash].js',
|
||||
assetFileNames: '[name].[ext]',
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
Loading…
Reference in New Issue
Block a user