forked from vitejs/vite
/
vite.config.js
46 lines (41 loc) · 1.18 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
import path from 'node:path'
import glob from 'fast-glob'
import { defineConfig, normalizePath } from 'vite'
/**
* @returns {import('vite').Plugin}
*/
function BackendIntegrationExample() {
return {
name: 'backend-integration',
config() {
const projectRoot = __dirname
const sourceCodeDir = path.join(projectRoot, 'frontend')
const root = path.join(sourceCodeDir, 'entrypoints')
const outDir = path.relative(root, path.join(projectRoot, 'dist/dev'))
const entrypoints = glob
.sync(`${normalizePath(root)}/**/*`, { onlyFiles: true })
.map((filename) => [path.relative(root, filename), filename])
entrypoints.push(['tailwindcss-colors', 'tailwindcss/colors.js'])
entrypoints.push(['bar.css', path.resolve(__dirname, './dir/foo.css')])
return {
build: {
manifest: true,
outDir,
rollupOptions: {
input: Object.fromEntries(entrypoints),
},
},
root,
resolve: {
alias: {
'~': sourceCodeDir,
},
},
}
},
}
}
export default defineConfig({
base: '/dev/',
plugins: [BackendIntegrationExample()],
})