Skip to content

Commit 660f6b5

Browse files
authored
Merge pull request #9 from SolidOS/fix/watch
configure toolkit for watch
2 parents 998a984 + eff2075 commit 660f6b5

3 files changed

Lines changed: 51 additions & 9 deletions

File tree

‎package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
},
2424
"scripts": {
2525
"build": "vp pack",
26-
"check": "vp check"
26+
"check": "vp check",
27+
"watch": "vp pack -w"
2728
},
2829
"dependencies": {
2930
"@babel/core": "^7.29.0",

‎src/vite/config/build.ts‎

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,32 @@ import { isAbsolute } from 'node:path';
22

33
import type { UserConfig } from 'vite';
44

5+
type BuildOutput = NonNullable<NonNullable<UserConfig['build']>['rolldownOptions']>['output'];
6+
57
export interface BuildConfigOptions {
68
entry: string;
79
overrides?: UserConfig['build'];
810
}
911

12+
function normalizeWatchOutputs(output: BuildOutput): BuildOutput {
13+
if (!output) {
14+
return output;
15+
}
16+
17+
const outputs = Array.isArray(output) ? output : [output];
18+
const watchOutputs = outputs.filter((output) => output.format !== 'cjs');
19+
20+
return Array.isArray(output)
21+
? watchOutputs
22+
: watchOutputs.length === 1
23+
? watchOutputs[0]
24+
: watchOutputs;
25+
}
26+
1027
export default function ({ entry, overrides }: BuildConfigOptions): UserConfig['build'] {
11-
return {
28+
const isWatch = process.argv.includes('--watch') || process.argv.includes('-w');
29+
30+
const build: UserConfig['build'] = {
1231
cssCodeSplit: true,
1332
sourcemap: true,
1433
lib: {
@@ -40,6 +59,20 @@ export default function ({ entry, overrides }: BuildConfigOptions): UserConfig['
4059
);
4160
},
4261
},
62+
};
63+
64+
const merged: UserConfig['build'] = {
65+
...build,
4366
...overrides,
67+
rolldownOptions: {
68+
...build.rolldownOptions,
69+
...overrides?.rolldownOptions,
70+
},
4471
};
72+
73+
if (isWatch && merged.rolldownOptions?.output) {
74+
merged.rolldownOptions.output = normalizeWatchOutputs(merged.rolldownOptions.output);
75+
}
76+
77+
return merged;
4578
}

‎src/vite/plugins/solid-pane.ts‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,25 @@ export interface SolidPanePluginOptions {
1414
}
1515

1616
export default function (options: SolidPanePluginOptions): PluginOption[] {
17-
return [
17+
const isWatch = process.argv.includes('--watch') || process.argv.includes('-w');
18+
19+
const plugins: PluginOption[] = [
1820
css(),
1921
icons(),
2022
raw(/\.ttl$/),
2123
babel({ litDecoratorPaths: options.litDecoratorPaths }),
22-
dts({
23-
tsconfigPath: 'tsconfig.json',
24-
entryRoot: 'src',
25-
outDirs: ['dist'],
26-
insertTypesEntry: true,
27-
}),
24+
...(isWatch
25+
? []
26+
: [
27+
dts({
28+
tsconfigPath: 'tsconfig.json',
29+
entryRoot: 'src',
30+
outDirs: ['dist'],
31+
insertTypesEntry: true,
32+
}),
33+
]),
2834
paneSandbox(options.sandbox),
2935
];
36+
37+
return plugins;
3038
}

0 commit comments

Comments
 (0)