This repository has been archived by the owner on Jan 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathvite.config.js
84 lines (80 loc) · 2.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// vite.config.js
import fs from "node:fs";
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import * as esbuild from "esbuild";
import path, { resolve } from "node:path";
const sourceJSPattern = /\/src\/.*\.js$/;
const rollupPlugin = (matchers) => ({
name: "js-in-jsx",
load(id) {
if (matchers.some(matcher => matcher.test(id))) {
const file = fs.readFileSync(id, { encoding: "utf-8" });
return esbuild.transformSync(file, { loader: "jsx" });
}
}
});
export default defineConfig({
plugins: [
react()
],
define: {
'process.platform': {}
},
build: {
target: "es2015",
lib: {
// Could also be a dictionary or array of multiple entry points
entry: resolve(__dirname, 'src/index.js'),
name: 'openVectorEditor',
// the proper extensions will be added
fileName: 'index',
formats: ['es', 'cjs', 'umd'],
},
rollupOptions: {
plugins: [
rollupPlugin([sourceJSPattern])
],
},
commonjsOptions: {
transformMixedEsModules: true,
},
},
optimizeDeps: {
esbuildOptions: {
loader: {
".js": "jsx",
},
},
},
resolve: {
alias: {
// "teselagen-react-components": console.log(`comment me out!`) || path.resolve(__dirname, "../teselagen-react-components/src"),
// "teselagen-react-components": "@teselagen/ui",
react: path.join(__dirname, "node_modules/react"),
"@blueprintjs/core": path.join(
__dirname,
"node_modules/@blueprintjs/core"
),
"@blueprintjs/datetime": path.join(
__dirname,
"node_modules/@blueprintjs/datetime"
),
"react-dom": path.join(__dirname, "node_modules/react-dom"),
"react-redux": path.join(__dirname, "node_modules/react-redux"),
"redux-form": path.join(__dirname, "node_modules/redux-form"),
redux: path.join(__dirname, "node_modules/redux"),
// "teselagen-react-components": path.resolve(__dirname, "../tg-oss/packages/ui/src"),
// "@teselagen/bounce-loader": path.resolve(__dirname, "../tg-oss/packages/bounce-loader/src"),
// "@teselagen/file-utils": path.resolve(__dirname, "../tg-oss/packages/file-utils/src"),
// "@teselagen/range-utils": path.resolve(__dirname, "../tg-oss/packages/range-utils/src"),
// "@teselagen/sequence-utils": path.resolve(__dirname, "../tg-oss/packages/sequence-utils/src"),
// "@teselagen/bio-parsers": path.resolve(__dirname, "../tg-oss/packages/bio-parsers/src"),
}
},
esbuild: {
loader: "jsx",
include: [sourceJSPattern],
exclude: [],
},
});