fix: update process.env to import.meta
This commit is contained in:
+29
-21
@@ -1,40 +1,48 @@
|
||||
import { defineConfig } from 'vitest/config'
|
||||
import { defineConfig } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
import { VitePWA } from 'vite-plugin-pwa';
|
||||
import { execSync } from 'node:child_process';
|
||||
import path from 'node:path';
|
||||
|
||||
let hash = '';
|
||||
try {
|
||||
hash = execSync('git rev-parse --short HEAD').toString().trim();
|
||||
const process = new Deno.Command('git', {
|
||||
args: ['rev-parse', '--short', 'HEAD'],
|
||||
stdout: 'piped'
|
||||
});
|
||||
const output = await process.output();
|
||||
hash = new TextDecoder().decode(output.stdout).trim();
|
||||
} catch (error) {
|
||||
console.error('Error getting git hash:', error);
|
||||
hash = 'DEV';
|
||||
}
|
||||
|
||||
console.log('Commit hash:', hash);
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react(),
|
||||
VitePWA({
|
||||
registerType: 'autoUpdate',
|
||||
strategies: 'generateSW',
|
||||
devOptions: {
|
||||
enabled: true
|
||||
},
|
||||
workbox: {
|
||||
cleanupOutdatedCaches: true,
|
||||
sourcemap: true
|
||||
}
|
||||
})
|
||||
plugins: [
|
||||
react(),
|
||||
VitePWA({
|
||||
registerType: 'autoUpdate',
|
||||
strategies: 'generateSW',
|
||||
devOptions: {
|
||||
enabled: true
|
||||
},
|
||||
workbox: {
|
||||
cleanupOutdatedCaches: true,
|
||||
sourcemap: true
|
||||
}
|
||||
})
|
||||
],
|
||||
define: {
|
||||
'process.env.COMMIT_HASH': JSON.stringify(hash),
|
||||
'import.meta.env.VITE_COMMIT_HASH': JSON.stringify(hash),
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'@app': path.resolve(__dirname, './src'),
|
||||
'@pages': path.resolve(__dirname, './src/pages'),
|
||||
'@components': path.resolve(__dirname, './src/components'),
|
||||
'@core': path.resolve(__dirname, './src/core'),
|
||||
'@layouts': path.resolve(__dirname, './src/layouts'),
|
||||
'@app': path.resolve(Deno.cwd(), './src'),
|
||||
'@pages': path.resolve(Deno.cwd(), './src/pages'),
|
||||
'@components': path.resolve(Deno.cwd(), './src/components'),
|
||||
'@core': path.resolve(Deno.cwd(), './src/core'),
|
||||
'@layouts': path.resolve(Deno.cwd(), './src/layouts'),
|
||||
},
|
||||
},
|
||||
server: {
|
||||
|
||||
Reference in New Issue
Block a user