-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
58 lines (56 loc) · 1.74 KB
/
vite.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { fileURLToPath } from 'node:url'
import { resolve, dirname } from 'node:path'
import react from '@vitejs/plugin-react'
import TranslationsLoader from './rollup/translations-loader-plugin'
import { extractMarketplaceTranslation } from './rollup/modifiers/translations'
import StaticCopy from './rollup/static-copy-plugin'
import { defineConfig, loadEnv } from 'vite'
import { changeLocation } from './rollup/modifiers/manifest'
import process from 'node:process'
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
export default ({ mode }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) }
return defineConfig({
base: './',
plugins: [
react(),
TranslationsLoader(),
StaticCopy({
targets: [
{ src: resolve(__dirname, 'src/assets/*'), dest: './' },
{ src: resolve(__dirname, 'src/manifest.json'), dest: '../', modifier: changeLocation },
{
src: resolve(__dirname, 'src/translations/en.json'),
dest: '../translations',
modifier: extractMarketplaceTranslation
}
]
})
],
root: 'src',
test: {
include: ['../{test,spec}/**/*.{test,spec}.{js,ts,jsx}'],
exclude: ['**/node_modules/**', '**/dist/**'],
globals: true,
environment: 'jsdom'
},
build: {
rollupOptions: {
input: {
main: resolve(__dirname, 'src/index.html')
},
output: {
entryFileNames: `[name].js`,
chunkFileNames: `[name].js`,
assetFileNames: `[name].[ext]`
},
watch: {
include: 'src/**'
}
},
outDir: resolve(__dirname, 'dist/assets'),
emptyOutDir: true
}
})
}