Skip to content

Commit

Permalink
test: add flatten=false tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed May 29, 2023
1 parent 393be65 commit 1a0faa4
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
4 changes: 3 additions & 1 deletion test/fixtures/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"dev:absolute": "vite --config vite.absolute.config.ts",
"build:absolute": "vite --config vite.absolute.config.ts build",
"dev:base": "vite --config vite.base.config.ts",
"build:base": "vite --config vite.base.config.ts build"
"build:base": "vite --config vite.base.config.ts build",
"dev:noflatten": "vite --config vite.noflatten.config.ts",
"build:noflatten": "vite --config vite.noflatten.config.ts build"
},
"devDependencies": {
"vite": "^4.3.5",
Expand Down
27 changes: 27 additions & 0 deletions test/fixtures/vite.noflatten.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { defineConfig } from 'vite'
import { viteStaticCopy } from 'vite-plugin-static-copy'

export default defineConfig({
build: {
outDir: './dist-noflatten'
},
plugins: [
viteStaticCopy({
targets: [
{
src: '*.txt',
dest: 'fixture1'
},
{
src: 'dir/*.txt',
dest: 'fixture2'
},
{
src: '../fixtures2/*.txt',
dest: 'fixture3'
}
],
flatten: false
})
]
})
1 change: 1 addition & 0 deletions test/fixtures2/baz.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fixture outside root
17 changes: 17 additions & 0 deletions test/testcases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,22 @@ export const testcases: Record<string, Testcase[]> = {
src: './foo.txt',
dest: '/base/fixture1/foo.txt'
}
],
'vite.noflatten.config.ts': [
{
name: 'glob without dir',
src: './foo.txt',
dest: '/fixture1/foo.txt'
},
{
name: 'glob with dir',
src: './dir/bar.txt',
dest: '/fixture2/bar.txt'
},
{
name: 'glob with parent dir',
src: '../fixtures2/baz.txt',
dest: '/fixture3/fixtures2/baz.txt'
}
]
}

0 comments on commit 1a0faa4

Please sign in to comment.