Skip to content

Commit 5671610

Browse files
committed
fix: resolve 'src' workspace path mismatches
- Add ignorePatterns for config files in eslint - Add vitest.workspace.ts to tsconfig.node.json - Fix vueI18n, path aliases for 'src' workspace - Refactor vitest.workspace.ts to use factory function
1 parent 1e6071b commit 5671610

File tree

4 files changed

+72
-79
lines changed

4 files changed

+72
-79
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module.exports = {
77
jquery: true,
88
},
99
extends: ['eslint:recommended', 'plugin:vue/vue3-recommended', 'prettier'],
10+
ignorePatterns: ['vitest.workspace.ts', 'vite.config.ts'],
1011
rules: {
1112
// override/add rules settings here, such as:
1213
// 'vue/no-unused-vars': 'error'

tsconfig.node.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
"module": "esnext",
55
"moduleResolution": "node"
66
},
7-
"include": ["vite.config.ts"]
7+
"include": ["vite.config.ts", "vitest.workspace.ts"]
88
}

vite.config.ts

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
import { defineConfig } from 'vite'
33
import vue from '@vitejs/plugin-vue'
44
import { fileURLToPath, URL } from 'url'
5-
import vueI18n from '@intlify/vite-plugin-vue-i18n'
5+
import { vueI18n } from '@intlify/vite-plugin-vue-i18n'
66

77
// https://github.com/vuetifyjs/vuetify-loader/tree/next/packages/vite-plugin
88
import vuetify from 'vite-plugin-vuetify'
9-
import { createHtmlPlugin } from 'vite-plugin-html'
10-
119
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'
1210

1311
// https://vitejs.dev/config/
@@ -21,22 +19,31 @@ export default defineConfig(() => {
2119
vuetify({ autoImport: true }),
2220
cssInjectedByJsPlugin(),
2321
vueI18n({
24-
// if you want to use Vue I18n Legacy API, you need to set `compositionOnly: false`
25-
// compositionOnly: false,
26-
27-
// you need to set i18n resource including paths !
2822
include: fileURLToPath(
29-
new URL(`./${version}/src/locales/**`, import.meta.url)
23+
new URL(
24+
version === 'src'
25+
? './src/locales/**'
26+
: `./${version}/src/locales/**`,
27+
import.meta.url
28+
)
3029
),
3130
}),
3231
],
3332
resolve: {
3433
alias: {
3534
'#': fileURLToPath(
36-
new URL(`./${version}/src`, import.meta.url)
35+
new URL(
36+
version === 'src' ? './src' : `./${version}/src`,
37+
import.meta.url
38+
)
3739
),
3840
'@': fileURLToPath(
39-
new URL(`./${version}/src/components`, import.meta.url)
41+
new URL(
42+
version === 'src'
43+
? './src/components'
44+
: `./${version}/src/components`,
45+
import.meta.url
46+
)
4047
),
4148
},
4249
},
@@ -60,19 +67,6 @@ export default defineConfig(() => {
6067
},
6168
},
6269
},
63-
// Test configuration is handled by vitest.workspace.ts
64-
// Removed to avoid conflicts with workspace projects
65-
// test: {
66-
// globals: true,
67-
// environment: 'jsdom',
68-
// server: {
69-
// deps: {
70-
// inline: ['vuetify'],
71-
// },
72-
// },
73-
// setupFiles: `./${version}/src/simulator/spec/vitestSetup.ts`,
74-
// },
75-
7670
server: {
7771
port: 4000,
7872
},

vitest.workspace.ts

Lines changed: 53 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,71 @@
1-
import { defineWorkspace } from 'vitest/config'
1+
import { defineWorkspace, defineConfig } from 'vitest/config'
22
import { dirname, join } from 'path'
33
import { fileURLToPath } from 'url'
4+
import vue from '@vitejs/plugin-vue'
5+
import vuetify from 'vite-plugin-vuetify'
6+
import { vueI18n } from '@intlify/vite-plugin-vue-i18n'
7+
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'
48
const __dirname = dirname(fileURLToPath(import.meta.url))
59

6-
export default defineWorkspace([
7-
{
8-
extends: './vite.config.ts',
9-
test: {
10-
name: 'src',
11-
environment: 'jsdom',
12-
globals: true,
13-
include: ['src/**/*.{spec,test}.{js,ts}'],
14-
exclude: ['v0/**/*', 'v1/**/*'],
15-
setupFiles: ['./src/simulator/spec/vitestSetup.ts'],
16-
server: {
17-
deps: {
18-
inline: ['vuetify'],
19-
},
20-
},
21-
},
10+
const createWorkspaceConfig = (version: string) =>
11+
defineConfig({
12+
plugins: [
13+
vue(),
14+
vuetify({ autoImport: true }),
15+
cssInjectedByJsPlugin(),
16+
vueI18n({
17+
include: fileURLToPath(
18+
new URL(
19+
version === 'src'
20+
? './src/locales/**'
21+
: `./${version}/src/locales/**`,
22+
import.meta.url
23+
)
24+
),
25+
}) as any,
26+
],
2227
resolve: {
2328
alias: {
24-
'#': join(__dirname, 'src'),
25-
'@': join(__dirname, 'src/components'),
29+
'#': join(
30+
__dirname,
31+
version === 'src' ? 'src' : `${version}/src`
32+
),
33+
'@': join(
34+
__dirname,
35+
version === 'src'
36+
? 'src/components'
37+
: `${version}/src/components`
38+
),
2639
},
2740
},
28-
},
29-
{
30-
extends: './vite.config.ts',
3141
test: {
32-
name: 'v0',
42+
name: version,
3343
environment: 'jsdom',
3444
globals: true,
35-
include: ['v0/src/**/*.{spec,test}.{js,ts}'],
36-
exclude: ['v1/**/*', 'src/**/*'],
37-
setupFiles: ['./v0/src/simulator/spec/vitestSetup.ts'],
45+
include: [
46+
version === 'src'
47+
? 'src/**/*.{spec,test}.{js,ts}'
48+
: `${version}/src/**/*.{spec,test}.{js,ts}`,
49+
],
50+
exclude:
51+
version === 'src'
52+
? ['v0/**/*', 'v1/**/*']
53+
: ['src/**/*', version === 'v0' ? 'v1/**/*' : 'v0/**/*'],
54+
setupFiles: [
55+
version === 'src'
56+
? './src/simulator/spec/vitestSetup.ts'
57+
: `./${version}/src/simulator/spec/vitestSetup.ts`,
58+
],
3859
server: {
3960
deps: {
4061
inline: ['vuetify'],
4162
},
4263
},
4364
},
44-
resolve: {
45-
alias: {
46-
'#': join(__dirname, 'v0/src'),
47-
'@': join(__dirname, 'v0/src/components'),
48-
},
49-
},
50-
},
51-
{
52-
extends: './vite.config.ts',
53-
test: {
54-
name: 'v1',
55-
environment: 'jsdom',
56-
globals: true,
57-
include: ['v1/src/**/*.{spec,test}.{js,ts}'],
58-
exclude: ['v0/**/*', 'src/**/*'],
59-
setupFiles: ['./v1/src/simulator/spec/vitestSetup.ts'],
60-
server: {
61-
deps: {
62-
inline: ['vuetify'],
63-
},
64-
},
65-
},
66-
resolve: {
67-
alias: {
68-
'#': join(__dirname, 'v1/src'),
69-
'@': join(__dirname, 'v1/src/components'),
70-
},
71-
},
72-
},
65+
})
66+
67+
export default defineWorkspace([
68+
createWorkspaceConfig('src'),
69+
createWorkspaceConfig('v0'),
70+
createWorkspaceConfig('v1'),
7371
])

0 commit comments

Comments
 (0)