generated from tooooools/boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
61 lines (51 loc) · 1.58 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
// TODO import @tooooools/ui by default
import path from 'path'
import { defineConfig, loadEnv } from 'vite'
// If a backend is needed, see https://vitejs.dev/guide/backend-integration.html
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
return {
root: path.join(__dirname, 'src'),
publicDir: path.join(__dirname, 'public'),
envDir: path.join(__dirname),
build: { outDir: path.join(__dirname, 'build') },
base: env.BASE || '/',
define: {
__NAME__: JSON.stringify(process.env.npm_package_name),
__REPOSITORY__: JSON.stringify(process.env.npm_package_repository_url),
__VERSION__: JSON.stringify(process.env.npm_package_version),
__RELEASE__: JSON.stringify(`${process.env.npm_package_name}@${process.env.npm_package_version}`)
},
plugins: [
{ // Replace index.jsx by test/test.jsx as entry in test mode
name: 'html-inject-test',
transformIndexHtml: html => mode === 'test' ? html.replace('/index.jsx', '/test/test.jsx') : html,
config: () => ({
resolve: {
alias: { '/test': path.join(__dirname, 'test') }
}
})
}
],
server: {
port: 8080,
host: true
},
css: {
devSourcemap: true,
preprocessorOptions: {
scss: {
additionalData: `
@use '/style/_helpers' as *;
@use '/style/_devices' as *;
$env: ${mode};
`
}
}
},
esbuild: {
jsxInject: "import { h } from '@tooooools/ui'",
jsxFactory: 'h'
}
}
})