-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.mts
63 lines (59 loc) · 1.91 KB
/
vite.config.mts
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { defineConfig } from 'vite';
import aurelia from '@aurelia/vite-plugin';
import path from 'path';
import typescript from '@rollup/plugin-typescript';
import { typescriptPaths } from 'rollup-plugin-typescript-paths';
import swc from 'unplugin-swc'
import * as packageJson from './package.json';
import { createFilter } from '@rollup/pluginutils';
const external: Array<string | RegExp> = Object.keys(packageJson.peerDependencies).concat(Object.keys(packageJson.dependencies)).concat([/(@material|devextreme)/] as any);
export const rawHtml = () => {
const filter = createFilter('*/.ts', undefined);
return {
name: 'raw',
transform: function transform(code: string, id: string) {
if (!filter(id)) return;
if (code.includes('__au2ViewDef')) return;
code = code.replaceAll(/(import .* from .*).html/g, '$1.html?raw');
return { code };
},
};
};
export default defineConfig({
plugins: [
aurelia({ enableConventions: true, hmr: true }),
swc.vite()
],
esbuild: {
target: 'es2022',
},
build: {
manifest: true,
minify: true,
target: 'es2022',
reportCompressedSize: true,
sourcemap: true,
lib: {
entry: path.resolve(__dirname, 'src/index.ts'),
name: '@betsybot/betsy-web-components',
fileName: 'index',
formats: ['es', 'cjs'],
},
rollupOptions: {
external,
plugins: [
typescriptPaths({
preserveExtensions: true,
}),
typescript({
sourceMap: true,
declaration: true,
outDir: 'dist',
exclude: ['**/__tests__'],
tsconfig: './tsconfig.build.json',
}),
rawHtml()
],
},
},
});