-
Notifications
You must be signed in to change notification settings - Fork 10
/
vite.config.ts
52 lines (51 loc) · 1.32 KB
/
vite.config.ts
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
/// <reference types="vitest" />
import { defineConfig } from "vite";
import babel from "vite-plugin-babel";
import { version } from "./package.json";
import { emscriptenPatch } from "./scripts/babel-plugin-emscripten-patch.js";
export default defineConfig({
build: {
target: ["es2020", "edge88", "firefox68", "chrome75", "safari13"],
lib: {
entry: {
"reader/index": "src/reader/index.ts",
"writer/index": "src/writer/index.ts",
"full/index": "src/full/index.ts",
},
formats: ["es"],
fileName: (_, entryName) => `${entryName}.js`,
},
outDir: "dist/es",
rollupOptions: {
output: {
chunkFileNames: "[name]-[hash].js",
manualChunks: (id) => {
if (
/core\.ts|exposedReaderBindings\.ts|exposedWriterBindings\.ts/.test(
id,
)
) {
return "core";
}
},
},
},
},
plugins: [
babel({
babelConfig: {
plugins: [emscriptenPatch()],
},
filter: /zxing_(reader|writer|full)\.js$/,
include: /zxing_(reader|writer|full)\.js$/,
}),
],
define: {
NPM_PACKAGE_VERSION: JSON.stringify(version),
"import.meta.vitest": "undefined",
},
test: {
testTimeout: 10000,
includeSource: ["src/bindings/barcodeFormat.ts"],
},
});