Skip to content

Commit eae8241

Browse files
frontend: remove unused ArduPilot parameter files from build
Only keep JSON files from the ArduPilot-Parameter-Repository, removing XML, RST, MD, and HTML documentation files that are not used by the frontend.
1 parent 271747a commit eae8241

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

core/frontend/vite.config.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,31 @@ export default defineConfig(({ command, mode }) => {
7777
next()
7878
})
7979
}
80-
}
80+
},
81+
// Remove non-JSON files from ArduPilot parameter repository to reduce image size
82+
{
83+
name: 'cleanup-ardupilot-files',
84+
apply: 'build',
85+
closeBundle() {
86+
const fs = require('fs')
87+
const repoPath = path.resolve(__dirname, 'dist/assets/ArduPilot-Parameter-Repository')
88+
if (!fs.existsSync(repoPath)) return
89+
90+
const removeNonJson = (dir) => {
91+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
92+
const fullPath = path.join(dir, entry.name)
93+
if (entry.isDirectory()) {
94+
removeNonJson(fullPath)
95+
} else if (!entry.name.endsWith('.json') && !entry.name.endsWith('.json.gz')) {
96+
fs.unlinkSync(fullPath)
97+
}
98+
}
99+
}
100+
removeNonJson(repoPath)
101+
}
102+
},
81103
],
82-
assetsInclude: ['**/*.gif', '**/*.glb', '**/*.png', '**/*.svg', '**/assets/ArduPilot-Parameter-Repository**.json', '**/*.msg', "**/three/examples/jsm/libs/draco/*"],
104+
assetsInclude: ['**/*.gif', '**/*.glb', '**/*.png', '**/*.svg', '**/*.msg', "**/three/examples/jsm/libs/draco/*"],
83105
resolve: {
84106
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'],
85107
alias: {

0 commit comments

Comments
 (0)