-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
100 lines (98 loc) · 2.89 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import { defineConfig } from 'vite';
import viteGlobImport from 'vite-plugin-sass-glob-import';
import path from 'path';
import { dxp } from './dxp/01_compilers/vite-plugins';
export default defineConfig(() => {
return {
publicDir: 'public',
build: {
rollupOptions: {
input: {
server: './src/entry-server.js',
main: './src/scripts/main.js'
},
output: {
dir: './dist',
entryFileNames: '[name].js',
chunkFileNames: '[name].js',
assetFileNames: '[name][extname]'
},
external: ['glob']
},
outDir: 'dist',
emptyOutDir: false
},
resolve: {
alias: {
'@global_components': path.resolve(
__dirname,
'./src/global_components'
),
'@dxp': path.resolve(__dirname, './dxp'),
'@components': path.resolve(__dirname, './dxp/component-service'),
'@styles': path.resolve(__dirname, './src/styles'),
'@common-styles': path.resolve(__dirname, './src/styles/common'),
'@scripts': path.resolve(__dirname, './src/scripts'),
'@pages': path.resolve(__dirname, './src/html'),
'@images': path.resolve(__dirname, './src/images')
}
},
server: {
open: true, // Opens the app in the browser when starting the dev server
port: 4000,
proxy: {
// Proxy all API calls or specific routes to another local server
'/cmp': {
target: 'http://localhost:3000', // Component server URL
changeOrigin: true,
rewrite: (path) => path.replace(/^\/cmp/, '/r/')
},
'/api': {
target: 'http://localhost:4000', // Your local server URL
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '/src/data')
},
'/__dxp/cdp/setConsent': {
target: 'http://localhost:4000', // Your local server URL
changeOrigin: true,
rewrite: (path) =>
path.replace(
/\/__dxp\/cdp\/setConsent/,
'/src/data/setConsent.json'
)
}
}
},
plugins: [viteGlobImport(), dxp()],
esbuild: {
supported: {
'top-level-await': true // browsers can handle top-level-await features
}
},
css: {
preprocessorOptions: {
scss: {
api: 'modern-compiler' // or "modern", "legacy"
}
}
},
test: {
globals: true,
environment: 'happy-dom' || 'node',
coverage: {
reporter: ['text-summary', 'html'],
include: [
'dxp/component-service/**/main.js',
'dxp/component-service/**/js/**/*.js',
'src/scripts/common/*.js'
],
exclude: ['node_modules', 'tests', '**/*.test.js'],
reportsDirectory: 'src/coverage',
lines: 90,
branches: 90,
functions: 90,
statements: 90
}
}
};
});