|
1 | 1 | import { defineConfig } from 'vite';
|
2 | 2 | import dts from 'vite-plugin-dts';
|
3 | 3 | import { visualizer } from 'rollup-plugin-visualizer';
|
4 |
| - |
5 | 4 | import { deepmerge } from 'deepmerge-ts';
|
6 | 5 |
|
7 | 6 | // https://vitejs.dev/config/
|
8 | 7 | const sharedConfig = ({ build = {}, plugins = [], ...rest }) => defineConfig({
|
9 |
| - build: deepmerge({ |
10 |
| - lib: { |
11 |
| - entry: { |
12 |
| - index: 'src/index.ts', |
| 8 | + build: deepmerge( |
| 9 | + { |
| 10 | + lib: { |
| 11 | + entry: 'src/index.ts', |
| 12 | + formats: ['iife'], // 'iife' bundles everything into one file |
| 13 | + name: 'PieCookieBanner', // Global variable for the component |
| 14 | + fileName: () => 'index.js', |
13 | 15 | },
|
14 |
| - formats: ['es'], |
15 |
| - }, |
16 |
| - rollupOptions: { |
17 |
| - external: (id) => { |
18 |
| - if (['react', '@lit/react'].includes(id)) { |
19 |
| - return true; |
20 |
| - } |
21 |
| - return false; |
| 16 | + rollupOptions: { |
| 17 | + external: [], // Ensure everything is bundled |
| 18 | + output: { |
| 19 | + globals: {}, // Define globals if you really want something external |
| 20 | + }, |
22 | 21 | },
|
| 22 | + outDir: 'cdn_dist', |
| 23 | + minify: 'terser', // Ensures smaller output |
23 | 24 | },
|
24 |
| - outDir: 'cdn_dist', |
25 |
| - }, build), |
26 |
| - test: { |
27 |
| - dir: '.', |
28 |
| - environment: 'jsdom', |
29 |
| - globals: true, |
30 |
| - include: [ |
31 |
| - './src/__tests__/**/*.{spec,test}.{js,ts}', |
32 |
| - './test/unit/**/*.{spec,test}.{js,ts}', |
| 25 | + build, |
| 26 | + ), |
| 27 | + plugins: deepmerge( |
| 28 | + [ |
| 29 | + dts({ |
| 30 | + insertTypesEntry: true, |
| 31 | + outputDir: 'cdn_dist', |
| 32 | + rollupTypes: true, |
| 33 | + }), |
| 34 | + visualizer({ |
| 35 | + gzipSize: true, |
| 36 | + brotliSize: true, |
| 37 | + }), |
33 | 38 | ],
|
34 |
| - exclude: ['**/node_modules/**'], |
35 |
| - }, |
36 |
| - plugins: deepmerge([dts({ |
37 |
| - insertTypesEntry: true, |
38 |
| - outputDir: 'cdn_dist', |
39 |
| - rollupTypes: true, |
40 |
| - }), |
41 |
| - visualizer({ |
42 |
| - gzipSize: true, |
43 |
| - brotliSize: true, |
44 |
| - })], plugins), |
45 |
| - |
| 39 | + plugins, |
| 40 | + ), |
46 | 41 | ...rest,
|
47 | 42 | });
|
48 | 43 |
|
|
0 commit comments