forked from Shopify/hydrogen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tsup.config.ts
49 lines (44 loc) · 1.32 KB
/
tsup.config.ts
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
import {defineConfig} from 'tsup';
import fs from 'fs-extra';
const commonConfig = {
format: 'esm',
minify: false,
bundle: false,
splitting: true,
treeshake: true,
sourcemap: false,
dts: true,
publicDir: 'templates',
};
export default defineConfig([
{
...commonConfig,
entry: ['src/**/*.ts'],
outDir: 'dist',
},
{
...commonConfig,
entry: ['src/virtual-routes/**/*.tsx'],
outDir: 'dist/virtual-routes',
clean: false, // Avoid deleting the assets folder
dts: false,
outExtension: () => ({js: '.jsx'}),
async onSuccess() {
// These files need to be packaged/distributed with the CLI
// so that we can use them in the `generate` command.
await fs.copy(
'../../templates/skeleton/app/routes',
'dist/generator-templates/routes',
{
filter: (filepath) =>
!/node_modules|\.cache|\.turbo|build|dist/gi.test(filepath),
},
);
console.log('\n', 'Copied template files to build directory', '\n');
// For some reason, it seems that publicDir => outDir might be skipped on CI,
// so ensure here that asset files are copied:
await fs.copy('src/virtual-routes/assets', 'dist/virtual-routes/assets');
console.log('\n', 'Copied virtual route assets to build directory', '\n');
},
},
]);