Skip to content

Commit 4461f56

Browse files
CopilotcyanzhongCopilot
authored
Add "copyDistFile" option to defaultViteConfig (#1)
* Initial plan * Add copyDistFile arg to defaultViteConfig Co-authored-by: cyanzhong <6745066+cyanzhong@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Document copyDistFile option in README Co-authored-by: cyanzhong <6745066+cyanzhong@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: cyanzhong <6745066+cyanzhong@users.noreply.github.com> Co-authored-by: Ying Zhong <0x00eeee@gmail.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent ab1f26c commit 4461f56

3 files changed

Lines changed: 5 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ If the `options` is not provided, or some values are missing, the following is u
3232
entry: 'main.ts',
3333
outDir: 'dist',
3434
destDir: '/Library/Containers/app.cyan.markedit/Data/Documents/scripts/',
35+
copyDistFile: true,
3536
}
3637
```
3738

main.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ function defaultViteConfig(args = {}) {
77
const entry = args.entry ?? 'main.ts';
88
const outDir = args.outDir ?? 'dist';
99
const destDir = args.destDir ?? '/Library/Containers/app.cyan.markedit/Data/Documents/scripts/';
10+
const copyDistFile = args.copyDistFile ?? true;
1011

1112
const rootDir = (() => {
1213
const stackTrace = Error.prepareStackTrace;
@@ -45,7 +46,7 @@ function defaultViteConfig(args = {}) {
4546
},
4647
},
4748
plugins: [
48-
{
49+
...(copyDistFile ? [{
4950
name: 'markedit-copy-dist-file',
5051
closeBundle: () => {
5152
const distDir = join(rootDir, outDir);
@@ -60,7 +61,7 @@ function defaultViteConfig(args = {}) {
6061
copyFileSync(sourcePath, destPath);
6162
console.log(`Successfully deployed to ${destPath}.`);
6263
},
63-
},
64+
}] : []),
6465
],
6566
};
6667
}

markedit-vite.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ export const defaultViteConfig: (args?: {
44
entry?: string;
55
outDir?: string;
66
destDir?: string;
7+
copyDistFile?: boolean;
78
}) => UserConfig;

0 commit comments

Comments
 (0)