-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
61 lines (59 loc) · 1.67 KB
/
vite.config.js
File metadata and controls
61 lines (59 loc) · 1.67 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
58
59
60
61
import { defineConfig } from 'vite';
import path from 'path';
import { fileURLToPath } from 'url';
import fs from 'fs';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
export default defineConfig({
root: '.',
base: './',
build: {
outDir: 'dist',
lib: {
entry: 'src/index.js',
name: 'OpenMagneticsVirtualBuilder',
fileName: (format) => `index.${format}.js`
},
rollupOptions: {
external: ['replicad', 'replicad-opencascadejs', 'opencascade.js'],
output: {
globals: {
replicad: 'replicad',
'replicad-opencascadejs': 'opencascadeWasm',
'opencascade.js': 'opencascade'
}
}
}
},
server: {
port: 3000,
open: false,
fs: {
// Allow serving files from node_modules and parent directories for test data
allow: ['..', '../..', '../../..', '../../../..']
}
},
plugins: [{
name: 'serve-test-data',
configureServer(server) {
// Serve testData from local tests/testData/
const testDataPath = path.resolve(__dirname, 'tests/testData');
server.middlewares.use('/testData', (req, res, next) => {
const filePath = path.join(testDataPath, req.url);
fs.readFile(filePath, (err, data) => {
if (err) {
res.statusCode = 404;
res.end('Not found: ' + req.url);
return;
}
res.setHeader('Content-Type', 'application/json');
res.end(data);
});
});
}
}],
assetsInclude: ['**/*.wasm'],
optimizeDeps: {
exclude: ['replicad-opencascadejs']
}
});