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

@@ -2,43 +2,144 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<% if (env.VITE_APP_INSTANCE === 'IMEX') { %>
<link rel="icon" href="/favicon.png" />
<% } %> <% if (env.VITE_APP_INSTANCE === 'ROME') { %>
<link rel="icon" href="/ro-favicon.png" />
<% } %> <% if (env.VITE_APP_INSTANCE === 'PROMANAGER') { %>
<link rel="icon" href="/favicon.png" />
<% } %>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#002366" />
<meta name="description" content="ImEX Online" />
<!-- <link rel="apple-touch-icon" href="logo192.png" /> -->
<link rel="apple-touch-icon" href="public/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<% if (env.VITE_APP_INSTANCE === 'IMEX') { %>
<meta name="description" content="ImEX Online" />
<title>ImEX Online</title>
<script type="text/javascript">
window.$crisp = [];
window.CRISP_WEBSITE_ID = "36724f62-2eb0-4b29-9cdd-9905fb99913e";
window.CRISP_WEBSITE_ID = '36724f62-2eb0-4b29-9cdd-9905fb99913e';
(function () {
d = document;
s = d.createElement("script");
s.src = "https://client.crisp.chat/l.js";
s = d.createElement('script');
s.src = 'https://client.crisp.chat/l.js';
s.async = 1;
d.getElementsByTagName("head")[0].appendChild(s);
d.getElementsByTagName('head')[0].appendChild(s);
})();
</script>
<% } %> <% if (env.VITE_APP_INSTANCE === 'ROME') { %>
<meta name="description" content="Rome Online" />
<title>Rome Online</title>
<!--Use the below code snippet to provide real time updates to the live chat plugin without the need of copying and paste each time to your website when changes are made via PBX-->
<call-us-selector phonesystem-url=https://rometech.east.3cx.us:5001 party="LiveChat528346"></call-us-selector>
<!--Incase you don't want real time updates to the live chat plugin when options are changed, use the below code snippet. Please note that each time you change the settings you will need to copy and paste the snippet code to your website-->
<!--<call-us
phonesystem-url=https://rometech.east.3cx.us:5001
style="position:fixed;font-size:16px;line-height:17px;z-index: 99999;right: 20px; bottom: 20px;"
id="wp-live-chat-by-3CX"
minimized="true"
animation-style="noanimation"
party="LiveChat528346"
minimized-style="bubbleright"
allow-call="true"
allow-video="false"
allow-soundnotifications="true"
enable-mute="true"
enable-onmobile="true"
offline-enabled="true"
enable="true"
ignore-queueownership="false"
authentication="both"
show-operator-actual-name="true"
aknowledge-received="true"
gdpr-enabled="false"
message-userinfo-format="name"
message-dateformat="both"
lang="browser"
button-icon-type="default"
greeting-visibility="none"
greeting-offline-visibility="none"
chat-delay="2000"
enable-direct-call="true"
enable-ga="false"
></call-us>-->
<script defer src=https://downloads-global.3cx.com/downloads/livechatandtalk/v1/callus.js id="tcx-callus-js" charset="utf-8"></script>
<% } %> <% if (env.VITE_APP_INSTANCE === 'PROMANAGER') { %>
<title>ProManager</title>
<meta name="description" content="ProManager" />
<% } %>
<script>
!(function () {
"use strict";
'use strict';
var e = [
"debug",
"destroy",
"do",
"help",
"identify",
"is",
"off",
"on",
"ready",
"render",
"reset",
"safe",
"set",
'debug',
'destroy',
'do',
'help',
'identify',
'is',
'off',
'on',
'ready',
'render',
'reset',
'safe',
'set',
];
if (window.noticeable)
console.warn("Noticeable SDK code snippet loaded more than once");
if (window.noticeable) console.warn('Noticeable SDK code snippet loaded more than once');
else {
var n = (window.noticeable = window.noticeable || []);
function t(e) {
@@ -54,30 +155,14 @@
}
})(),
(function () {
var e = document.createElement("script");
(e.async = !0), (e.src = "https://sdk.noticeable.io/l.js");
var e = document.createElement('script');
(e.async = !0), (e.src = 'https://sdk.noticeable.io/l.js');
var n = document.head;
n.insertBefore(e, n.firstChild);
})();
}
})();
</script>
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>ImEX Online</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>

View File

@@ -86,6 +86,7 @@
"styled-components": "^6.1.8",
"subscriptions-transport-ws": "^0.11.0",
"terser-webpack-plugin": "^5.3.10",
"vite-plugin-ejs": "^1.7.0",
"vite-plugin-svgr": "^4.2.0",
"web-vitals": "^3.5.2",
"workbox-core": "^7.0.0",
@@ -26836,6 +26837,17 @@
"vite": "^2.7.0 || ^3.0.0 || ^4.0.0 || ^5.0.0"
}
},
"node_modules/vite-plugin-ejs": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/vite-plugin-ejs/-/vite-plugin-ejs-1.7.0.tgz",
"integrity": "sha512-JNP3zQDC4mSbfoJ3G73s5mmZITD8NGjUmLkq4swxyahy/W0xuokK9U9IJGXw7KCggq6UucT6hJ0p+tQrNtqTZw==",
"dependencies": {
"ejs": "^3.1.9"
},
"peerDependencies": {
"vite": ">=5.0.0"
}
},
"node_modules/vite-plugin-legacy": {
"version": "2.1.0",
"dev": true,

View File

@@ -86,6 +86,7 @@
"styled-components": "^6.1.8",
"subscriptions-transport-ws": "^0.11.0",
"terser-webpack-plugin": "^5.3.10",
"vite-plugin-ejs": "^1.7.0",
"vite-plugin-svgr": "^4.2.0",
"web-vitals": "^3.5.2",
"workbox-core": "^7.0.0",
@@ -139,8 +140,8 @@
},
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@dotenvx/dotenvx": "^0.15.0",
"@babel/preset-react": "^7.23.3",
"@dotenvx/dotenvx": "^0.15.0",
"@emotion/babel-plugin": "^11.11.0",
"@emotion/react": "^11.11.3",
"@sentry/webpack-plugin": "^2.14.2",

View File

@@ -378,7 +378,7 @@ function Header({
...(InstanceRenderManager({
imex: true,
rome: true,
promanager: HasFeatureAccess({ featureName: 'courtesycards', bodyshop }),
promanager: false// HasFeatureAccess({ featureName: 'courtesycars', bodyshop }),
})
? [
{

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'],
// // },
// }
});