forked from Revvity/teselagen-react-components
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
74 lines (72 loc) · 2.21 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
// 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"),
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/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: []
}
});