-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
34 lines (31 loc) · 883 Bytes
/
vite.config.js
File metadata and controls
34 lines (31 loc) · 883 Bytes
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
import { defineConfig } from "vite";
import replace from "@rollup/plugin-replace";
import path from "path";
import fs from "fs";
const packageJsonPath = path.resolve(__dirname, "package.json");
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
const replaceJsonPath = path.resolve(
__dirname,
"builder_config/webgl.variables.json"
);
const replaceMap = JSON.parse(fs.readFileSync(replaceJsonPath, "utf-8"));
replaceMap["{{appVersion}}"] = packageJson.version;
replaceMap["{{date}}"] = Date.now().toString();
export default defineConfig({
build: {
lib: {
entry: "src/index.js",
name: "PWGL",
fileName: (format) => `pwgl.${format}.min.js`,
formats: ["es", "umd"],
},
minify: "terser",
emptyOutDir: false,
},
plugins: [
replace({
preventAssignment: true,
values: replaceMap,
}),
],
});