From abdfc3894188bf7bb0fb2d8835dcab5005b98c16 Mon Sep 17 00:00:00 2001 From: Maleh Duenas Date: Wed, 14 Aug 2024 10:05:47 +0200 Subject: [PATCH] chore(pie-cookie-banner): DSW-000 add a build config to bundle cookie-banner with all deps --- .../pie-cookie-banner/cdn.vite.confg.js | 49 +++++++++++++++++++ .../components/pie-cookie-banner/package.json | 1 + 2 files changed, 50 insertions(+) create mode 100644 packages/components/pie-cookie-banner/cdn.vite.confg.js diff --git a/packages/components/pie-cookie-banner/cdn.vite.confg.js b/packages/components/pie-cookie-banner/cdn.vite.confg.js new file mode 100644 index 0000000000..8b195fe1b9 --- /dev/null +++ b/packages/components/pie-cookie-banner/cdn.vite.confg.js @@ -0,0 +1,49 @@ +import { defineConfig } from 'vite'; +import dts from 'vite-plugin-dts'; +import { visualizer } from 'rollup-plugin-visualizer'; + +import { deepmerge } from 'deepmerge-ts'; + +// https://vitejs.dev/config/ +const sharedConfig = ({ build = {}, plugins = [], ...rest }) => defineConfig({ + build: deepmerge({ + lib: { + entry: { + index: 'src/index.ts', + }, + formats: ['es'], + }, + rollupOptions: { + external: (id) => { + if (['react', '@lit/react'].includes(id)) { + return true; + } + return false; + }, + }, + outDir: 'cdn_dist', + }, build), + test: { + dir: '.', + environment: 'jsdom', + globals: true, + include: [ + './src/__tests__/**/*.{spec,test}.{js,ts}', + './test/unit/**/*.{spec,test}.{js,ts}', + ], + exclude: ['**/node_modules/**'], + }, + plugins: deepmerge([dts({ + insertTypesEntry: true, + outputDir: 'cdn_dist', + rollupTypes: true, + }), + visualizer({ + gzipSize: true, + brotliSize: true, + })], plugins), + + ...rest, +}); + +export default sharedConfig; diff --git a/packages/components/pie-cookie-banner/package.json b/packages/components/pie-cookie-banner/package.json index 803bc7e6cf..9e68817848 100644 --- a/packages/components/pie-cookie-banner/package.json +++ b/packages/components/pie-cookie-banner/package.json @@ -18,6 +18,7 @@ }, "scripts": { "build": "run -T vite build", + "build:cdn": "run -T vite build --config './cdn.vite.confg.js'", "build:react-wrapper": "npx build-react-wrapper", "create:manifest": "yarn cem analyze --litelement", "lint:scripts": "run -T eslint .",