45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
// @ts-check
|
|
import { dirname, resolve } from 'path'
|
|
import { fileURLToPath } from 'url'
|
|
import { defineConfig } from 'vite'
|
|
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
|
|
// UMD Bundle for CDN
|
|
// - alias all local packages so that they can be build in
|
|
// - no external
|
|
// - no d.ts. dts does not work with monorepo aliasing
|
|
export default defineConfig({
|
|
plugins: [cssInjectedByJsPlugin({ relativeCSSInjection: true })],
|
|
publicDir: false,
|
|
esbuild: {
|
|
keepNames: true,
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@page-agent/page-controller': resolve(__dirname, '../page-controller/src/PageController.ts'),
|
|
'@page-agent/ui': resolve(__dirname, '../ui/src/index.ts'),
|
|
},
|
|
},
|
|
build: {
|
|
lib: {
|
|
entry: resolve(__dirname, 'src/umd.ts'),
|
|
name: 'PageAgent',
|
|
fileName: 'page-agent',
|
|
formats: ['umd'],
|
|
},
|
|
outDir: resolve(__dirname, 'dist', 'umd'),
|
|
rollupOptions: {
|
|
output: {
|
|
// force use .js as extension
|
|
entryFileNames: 'page-agent.js',
|
|
},
|
|
},
|
|
cssCodeSplit: true,
|
|
},
|
|
define: {
|
|
'process.env.NODE_ENV': '"production"',
|
|
},
|
|
})
|