Dynamically update index.html with correct build values.

This commit is contained in:
Patrick Fic
2024-02-26 12:46:33 -08:00
parent 2d07c20ea8
commit 42aa42c892
5 changed files with 147 additions and 122 deletions

View File

@@ -1,19 +1,10 @@
import legacy from '@vitejs/plugin-legacy';
import react from '@vitejs/plugin-react';
import { createRequire } from 'module';
import { defineConfig, transformWithEsbuild } from 'vite';
import { promises as fsPromises } from 'fs';
import * as url from 'url';
import { createRequire } from 'module';
import * as path from 'path';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
import {
AndDesignVueResolve,
AntdResolve,
createStyleImportPlugin,
ElementPlusResolve,
NutuiResolve,
VantResolve,
} from 'vite-plugin-style-import';
import * as url from 'url';
import { defineConfig } from 'vite';
import { ViteEjsPlugin } from 'vite-plugin-ejs';
process.env.VITE_APP_GIT_SHA_DATE = new Date().toLocaleString('en-US', {
timeZone: 'America/Los_Angeles',
@@ -44,88 +35,24 @@ function reactVirtualized() {
export default defineConfig({
base: '/',
plugins: [
// {
// name: 'treat-js-files-as-jsx',
// async transform(code, id) {
// if (!id.match(/src\/.*\.js$/)) return null
ViteEjsPlugin((viteConfig) => {
// viteConfig is the current Vite resolved config
return { env: viteConfig.env };
}),
// return transformWithEsbuild(code, id, {
// loader: 'jsx',
// jsx: 'automatic',
// })
// },
// },
reactVirtualized(),
react(),
// nodePolyfills({
// protocolImports: true,
// overrides: {
// // Since `fs` is not supported in browsers, we can use the `memfs` package to polyfill it.
// fs: 'memfs',
// // Since `path` is not supported in browsers, we can use the `path-browserify` package to polyfill it.
// path: 'path-browserify',
// // Since `os` is not supported in browsers, we can use the `os-browserify` package to polyfill it.
// os: 'os-browserify/browser',
// // Since `crypto` is not supported in browsers, we can use the `crypto-browserify` package to polyfill it.
// crypto: 'crypto-browserify',
// // Since `stream` is not supported in browsers, we can use the `stream-browserify` package to polyfill it.
// stream: 'stream-browserify',
// // Since `buffer` is not supported in browsers, we can use the `buffer` package to polyfill it.
// }
// }),
// createStyleImportPlugin({
// resolves: [
// AndDesignVueResolve(),
// VantResolve(),
// ElementPlusResolve(),
// NutuiResolve(),
// AntdResolve(),
// ],
// libs: [
// {
// libraryName: 'ant-design-vue',
// esModule: true,
// resolveStyle: (name) => {
// return `ant-design-vue/es/${name}/style/index`
// },
// },
// ]
// }),
// legacy({
// targets: ['defaults']
// }),
],
// css: {
// preprocessorOptions: {
// less: {
// javascriptEnabled: true,
// modifyVars: {
// ...v4Token,
// },
// }
// }
// },
server: {
host: true,
port: 3000,
open: true,
},
optimizeDeps: {
// force: true,
esbuildOptions: {
loader: {
'.js': 'jsx',
},
},
},
// build: {
// outDir: 'build',
// // manifest: true,
// // sourcemap: true,
// // rollupOptions: {
// // external: ['antd'],
// // },
// }
});