fix(cap-vite): don't auto restart when generated files update
This commit is contained in:
@@ -76,6 +76,12 @@ describe('shouldRestartForNativeChange', () => {
|
||||
expect(shouldRestartForNativeChange('/repo/app/src/main.ts', 'ios', '/repo/app')).toBe(false)
|
||||
expect(shouldRestartForNativeChange('/repo/app/ios/App/CapApp-SPM/Package.swift', 'ios', '/repo/app')).toBe(false)
|
||||
expect(shouldRestartForNativeChange('/repo/app/android/build/generated/file.kt', 'android', '/repo/app')).toBe(false)
|
||||
expect(shouldRestartForNativeChange('/repo/app/android/capacitor-cordova-android-plugins/src/main/AndroidManifest.xml', 'android', '/repo/app')).toBe(false)
|
||||
expect(shouldRestartForNativeChange('/repo/app/android/capacitor.settings.gradle', 'android', '/repo/app')).toBe(false)
|
||||
expect(shouldRestartForNativeChange('/repo/app/android/app/capacitor.build.gradle', 'android', '/repo/app')).toBe(false)
|
||||
expect(shouldRestartForNativeChange('/repo/app/android/app/src/main/assets/public/index.html', 'android', '/repo/app')).toBe(false)
|
||||
expect(shouldRestartForNativeChange('/repo/app/android/app/src/main/assets/capacitor.plugins.json', 'android', '/repo/app')).toBe(false)
|
||||
expect(shouldRestartForNativeChange('/repo/app/android/app/src/main/res/xml/config.xml', 'android', '/repo/app')).toBe(false)
|
||||
})
|
||||
|
||||
it('ignores capacitor config json updates', () => {
|
||||
|
||||
@@ -66,7 +66,14 @@ const ignoredPathPrefixesByPlatform: Record<CapacitorPlatform, string[][]> = {
|
||||
ios: [
|
||||
['App', 'CapApp-SPM'],
|
||||
],
|
||||
android: [],
|
||||
android: [
|
||||
['app', 'src', 'main', 'assets', 'public'],
|
||||
['app', 'src', 'main', 'assets', 'capacitor.plugins.json'],
|
||||
['app', 'src', 'main', 'res', 'xml', 'config.xml'],
|
||||
['app', 'capacitor.build.gradle'],
|
||||
['capacitor-cordova-android-plugins'],
|
||||
['capacitor.settings.gradle'],
|
||||
],
|
||||
}
|
||||
|
||||
export function parseCapacitorPlatform(value: string | undefined): CapacitorPlatform | null {
|
||||
@@ -128,7 +135,8 @@ export function shouldRestartForNativeChange(file: string, platform: CapacitorPl
|
||||
prefix.every((segment, index) => relativeSegments[index] === segment),
|
||||
)) {
|
||||
// NOTICE: Capacitor regenerates ios/App/CapApp-SPM/Package.swift during `cap run`.
|
||||
// Treating that generated tree as a native source change causes an infinite restart loop.
|
||||
// It also rewrites several generated Android files and plugin trees during `cap update`.
|
||||
// Treating those generated outputs as native source changes causes an infinite restart loop.
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user