forked from trent_larson/crowd-funder-for-time-pwa
- Fix .dockerignore to allow dist directory for Docker builds - Add uint8arrays dependency for crypto operations - Configure Vite for proper SQL worker bundling with absurd-sql - Update Dockerfile with build context documentation - Fix Nginx configuration for non-root user permissions - Remove conflicting backend proxy configuration - Add SQL worker polyfills to vite.config.common.mts Resolves Docker build failures and ensures proper SQL database functionality in containerized environment.
100 lines
2.7 KiB
TypeScript
100 lines
2.7 KiB
TypeScript
import { defineConfig, mergeConfig } from "vite";
|
|
import { createBuildConfig } from "./vite.config.common.mts";
|
|
import { loadAppConfig } from "./vite.config.utils.mts";
|
|
|
|
export default defineConfig(async ({ mode }) => {
|
|
const baseConfig = await createBuildConfig('web');
|
|
const appConfig = await loadAppConfig();
|
|
|
|
// Environment-specific configuration based on mode
|
|
const getEnvironmentConfig = (mode: string) => {
|
|
switch (mode) {
|
|
case 'production':
|
|
return {
|
|
// Production optimizations
|
|
build: {
|
|
minify: 'terser',
|
|
sourcemap: false,
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks: {
|
|
vendor: ['vue', 'vue-router', 'pinia'],
|
|
utils: ['luxon', 'ramda', 'zod'],
|
|
crypto: ['@ethersproject/wallet', '@ethersproject/hdnode', 'ethereum-cryptography'],
|
|
sql: ['@jlongster/sql.js', 'absurd-sql']
|
|
}
|
|
}
|
|
}
|
|
},
|
|
define: {
|
|
__DEV__: false,
|
|
__TEST__: false,
|
|
__PROD__: true
|
|
}
|
|
};
|
|
case 'test':
|
|
return {
|
|
// Test environment configuration
|
|
build: {
|
|
minify: false,
|
|
sourcemap: true,
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks: undefined
|
|
}
|
|
}
|
|
},
|
|
define: {
|
|
__DEV__: false,
|
|
__TEST__: true,
|
|
__PROD__: false
|
|
}
|
|
};
|
|
default: // development
|
|
return {
|
|
// Development configuration
|
|
build: {
|
|
minify: false,
|
|
sourcemap: true,
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks: undefined
|
|
}
|
|
}
|
|
},
|
|
define: {
|
|
__DEV__: true,
|
|
__TEST__: false,
|
|
__PROD__: false
|
|
}
|
|
};
|
|
}
|
|
};
|
|
|
|
const environmentConfig = getEnvironmentConfig(mode);
|
|
|
|
return mergeConfig(baseConfig, {
|
|
...environmentConfig,
|
|
// Ensure source maps are enabled for development and test modes
|
|
// This affects both dev server and build output
|
|
sourcemap: mode === 'development' || mode === 'test',
|
|
// Server configuration inherited from base config
|
|
// CORS headers removed to allow images from any domain
|
|
plugins: [],
|
|
// Worker configuration for SQL worker
|
|
worker: {
|
|
format: 'es',
|
|
plugins: () => []
|
|
},
|
|
// Optimize dependencies for SQL worker
|
|
optimizeDeps: {
|
|
include: [
|
|
'@jlongster/sql.js',
|
|
'absurd-sql',
|
|
'absurd-sql/dist/indexeddb-main-thread',
|
|
'absurd-sql/dist/indexeddb-backend'
|
|
]
|
|
}
|
|
});
|
|
});
|