chore(frontend+infra): optimize build process and exclude SQLite workers from minification
- Updated Webpack config to exclude SQLite workers from parsing and Terser minification, fixing related errors and improving build speed. - Adjusted Dockerfile to disable source maps for production builds, reducing build time and memory usage. - Modified Gradle build configuration to respect the `noSourceMaps` flag during Docker builds.
This commit is contained in:
@@ -39,6 +39,11 @@ kotlin {
|
||||
KotlinWebpackConfig.Mode.PRODUCTION
|
||||
else
|
||||
KotlinWebpackConfig.Mode.DEVELOPMENT
|
||||
|
||||
// Source Maps Optimierung für Docker Builds
|
||||
if (project.hasProperty("noSourceMaps")) {
|
||||
sourceMaps = false
|
||||
}
|
||||
}
|
||||
|
||||
webpackTask {
|
||||
|
||||
@@ -136,3 +136,28 @@ config.devServer.devMiddleware.mimeTypes = {
|
||||
'application/wasm': ['wasm'],
|
||||
'application/javascript': ['js']
|
||||
};
|
||||
|
||||
// 10. OPTIMIZATION: Exclude SQLite workers from parsing and minification
|
||||
// This fixes the "return outside of function" error in Terser and speeds up build
|
||||
config.module.noParse = config.module.noParse || [];
|
||||
if (Array.isArray(config.module.noParse)) {
|
||||
config.module.noParse.push(/sqlite3-worker1\.mjs/);
|
||||
config.module.noParse.push(/sqlite3\.mjs/);
|
||||
} else {
|
||||
// If it's a function or RegExp, we wrap it (simplified for now, assuming array or undefined)
|
||||
config.module.noParse = [config.module.noParse, /sqlite3-worker1\.mjs/, /sqlite3\.mjs/];
|
||||
}
|
||||
|
||||
if (config.optimization && config.optimization.minimizer) {
|
||||
config.optimization.minimizer.forEach(minimizer => {
|
||||
if (minimizer.constructor.name === 'TerserPlugin') {
|
||||
minimizer.options.exclude = minimizer.options.exclude || [];
|
||||
const excludePattern = /sqlite3-worker1\.mjs/;
|
||||
if (Array.isArray(minimizer.options.exclude)) {
|
||||
minimizer.options.exclude.push(excludePattern);
|
||||
} else {
|
||||
minimizer.options.exclude = [minimizer.options.exclude, excludePattern];
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user