-
Notifications
You must be signed in to change notification settings - Fork 380
Expand file tree
/
Copy pathvite.config.js
More file actions
57 lines (49 loc) · 1.64 KB
/
vite.config.js
File metadata and controls
57 lines (49 loc) · 1.64 KB
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
import { searchForWorkspaceRoot, loadEnv } from 'vite';
import fs from 'fs';
import react from '@vitejs/plugin-react';
import path from 'path';
// alias order matters so longer paths are listed first
export const packageAliases = {
'3d-tiles-renderer/core/plugins': path.resolve( './src/core/plugins/index.js' ),
'3d-tiles-renderer/three/plugins': path.resolve( './src/three/plugins/index.js' ),
'3d-tiles-renderer/r3f': path.resolve( './src/r3f/index.jsx' ),
'3d-tiles-renderer/core': path.resolve( './src/core/renderer/index.js' ),
'3d-tiles-renderer/three': path.resolve( './src/three/renderer/index.js' ),
'3d-tiles-renderer/babylonjs': path.resolve( './src/babylonjs/renderer/index.js' ),
'3d-tiles-renderer/plugins': path.resolve( './src/plugins.js' ),
'3d-tiles-renderer': path.resolve( './src/index.js' ),
};
export default ( { mode } ) => {
process.env = { ...process.env, ...loadEnv( mode, process.cwd() ) };
const useBuild = mode === 'use-build';
return {
root: './example/',
envDir: '.',
base: '',
resolve: {
alias: useBuild ? null : packageAliases,
},
build: {
sourcemap: true,
outDir: './bundle/',
rollupOptions: {
input: [
...fs.readdirSync( './example/three/' ).map( name => 'three/' + name ),
...fs.readdirSync( './example/r3f/' ).map( name => 'r3f/' + name ),
...fs.readdirSync( './example/babylonjs/' ).map( name => 'babylonjs/' + name ),
]
.filter( p => /\.html$/.test( p ) )
.map( p => `./example/${ p }` ),
},
},
server: {
fs: {
allow: [
// search up for workspace root
searchForWorkspaceRoot( process.cwd() ),
],
},
},
plugins: [ react() ],
};
};