Skip to content

Commit

Permalink
feat(plugin-vite): remove copy to built App
Browse files Browse the repository at this point in the history
  • Loading branch information
caoxiemeihao committed May 4, 2024
1 parent bb1fc52 commit a517c24
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 43 deletions.
37 changes: 2 additions & 35 deletions packages/plugin/vite/src/VitePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { PRESET_TIMER } from 'listr2';
// eslint-disable-next-line node/no-unpublished-import
import { default as vite } from 'vite';

import { getFlatDependencies } from './util/package';
import { onBuildDone } from './util/plugins';
import ViteConfigGenerator from './ViteConfig';

Expand Down Expand Up @@ -92,46 +91,14 @@ Your packaged app may be larger than expected if you dont ignore everything othe
return forgeConfig;
}

const flatDeps = await getFlatDependencies(this.projectDir);
const names = flatDeps.map((dep) => dep.name);
forgeConfig.packagerConfig.ignore = (file: string) => {
if (!file) return false;

// `file` always starts with `/`
// @see - https://github.com/electron/packager/blob/v18.1.3/src/copy-filter.ts#L89-L93

// Collect dependencies from package.json by default
if (file.startsWith('/node_modules')) {
const [, , orgOrName, sub] = file.split('/');

if (orgOrName) {
if (orgOrName.startsWith('@')) {
if (sub) {
// /node_modules/@org/name
const name = `${orgOrName}/${sub}`;

if (names.includes(name)) return false;
} else {
// /node_modules/@org
return names.some((name) => name.startsWith(orgOrName)) ? false : true;
}
} else {
const name = orgOrName;

if (names.includes(name)) return false;

// .bin, .vite, .yarn-integrity etc
// TODO: Something must be explicitly filtered out here, prehaps this a BUG of `ignore`
if (name.startsWith('.')) return true;
}
}
} else {
// Collect the files built by Vite
return !file.startsWith('/.vite');
}

// TODO: return false behavior diff than reutrn undefined, prehaps this a BUG of `ignore`
return undefined as unknown as boolean;
// Collect the files built by Vite
return !file.startsWith('/.vite');
};
return forgeConfig;
};
Expand Down
8 changes: 0 additions & 8 deletions packages/plugin/vite/src/util/package.ts

This file was deleted.

0 comments on commit a517c24

Please sign in to comment.