Files
archived-x-prober/prod.vite.config.mjs
2025-08-15 10:39:40 +08:00

56 lines
1.4 KiB
JavaScript

import { existsSync, mkdirSync } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';
const __dirname = dirname(fileURLToPath(import.meta.url));
const tmpDir = resolve(__dirname, '.tmp');
if (!existsSync(tmpDir)) {
mkdirSync(tmpDir);
}
export default defineConfig({
mode: 'production',
root: __dirname,
build: {
lib: {
entry: resolve(__dirname, 'src/main.tsx'),
name: 'app',
fileName: () => 'app.js',
formats: ['umd'],
cssFileName: 'app',
},
outDir: tmpDir,
sourcemap: 'hidden',
emptyOutDir: true,
target: 'esnext',
// rollupOptions:{
// output: {
// assetFileNames: (assetInfo) => {
// for(const name of assetInfo.names) {
// if (name.endsWith('.css')) {
// return 'app.css';
// }
// }
// }
// }
// }
},
resolve: {
alias: {
'@': resolve(__dirname, 'src/'),
},
extensions: ['.ts', '.tsx', '.js', '.mjs'],
},
define: {
__DEV__: false,
DEBUG: false,
'process.env': {
NODE_ENV: JSON.stringify('production'),
WEBPACK_ENV: JSON.stringify('production'),
},
},
plugins: [react(), tsconfigPaths()],
});