-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
38 lines (35 loc) · 965 Bytes
/
vite.config.ts
File metadata and controls
38 lines (35 loc) · 965 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
35
36
37
38
import { defineConfig, type Plugin } from "vite-plus";
import pkg from "./package.json" with { type: "json" };
const banner = `/*!
* ${pkg.name} v${pkg.version}
* TypeScript port of google/data-layer-helper
* (c) David Vallejo / Analytics Debugger S.L.U. - https://github.com/thyngster
* Apache-2.0 License
*/`;
function bannerPlugin(): Plugin {
return {
name: "banner",
generateBundle(_, bundle) {
for (const chunk of Object.values(bundle)) {
if (chunk.type === "chunk") {
chunk.code = banner + "\n" + chunk.code;
}
}
},
};
}
export default defineConfig({
build: {
lib: {
entry: "src/index.ts",
formats: ["es", "cjs", "iife"],
name: "DataLayerHelper",
fileName: (format) => {
if (format === "es") return "index.js";
if (format === "cjs") return "index.cjs";
return "data-layer-helper.iife.js";
},
},
},
plugins: [bannerPlugin()],
});