Skip to content

Commit cacd0f5

Browse files
committed
make default config export
1 parent 11e4377 commit cacd0f5

File tree

3 files changed

+27
-24
lines changed

3 files changed

+27
-24
lines changed
Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
11
import { defineConfig } from 'vite';
22
import { rmSync } from 'fs';
3+
import { getDefaultConfig } from '../../vite-config-base';
34

45
const dist = '../../../dist-cms/packages/dictionary';
56

67
// delete the unbundled dist folder
78
rmSync(dist, { recursive: true, force: true });
89

910
export default defineConfig({
10-
build: {
11-
target: 'es2022',
12-
lib: {
13-
entry: ['index.ts', 'manifests.ts', 'umbraco-package.ts'],
14-
formats: ['es'],
15-
},
16-
outDir: dist,
17-
sourcemap: true,
18-
rollupOptions: {
19-
external: [/^@umbraco/],
20-
},
21-
},
11+
...getDefaultConfig({ dist }),
2212
});

src/packages/webhook/vite.config.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
11
import { defineConfig } from 'vite';
22
import { rmSync } from 'fs';
3+
import { getDefaultConfig } from '../../vite-config-base';
34

45
const dist = '../../../dist-cms/packages/webhook';
56

67
// delete the unbundled dist folder
78
rmSync(dist, { recursive: true, force: true });
89

910
export default defineConfig({
10-
build: {
11-
target: 'es2022',
12-
lib: {
13-
entry: ['index.ts', 'manifests.ts', 'umbraco-package.ts'],
14-
formats: ['es'],
15-
},
16-
outDir: dist,
17-
sourcemap: true,
18-
rollupOptions: {
19-
external: [/^@umbraco/],
20-
},
21-
},
11+
...getDefaultConfig({ dist }),
2212
});

src/vite-config-base.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { UserConfig } from 'vite';
2+
3+
interface UmbViteDefaultConfigArgs {
4+
dist: string;
5+
entry?: string[];
6+
}
7+
8+
export const getDefaultConfig = (args: UmbViteDefaultConfigArgs): UserConfig => {
9+
return {
10+
build: {
11+
target: 'es2022',
12+
lib: {
13+
entry: args.entry || ['index.ts', 'manifests.ts', 'umbraco-package.ts'],
14+
formats: ['es'],
15+
},
16+
outDir: args.dist,
17+
sourcemap: true,
18+
rollupOptions: {
19+
external: [/^@umbraco/],
20+
},
21+
},
22+
};
23+
};

0 commit comments

Comments
 (0)