Skip to content

Commit

Permalink
busting cache changing resource location
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianscatularo committed Mar 11, 2024
1 parent 5fd1283 commit da3941d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ jobs:
PUBLIC_URL: ${{ inputs.public-url }}
VITE_APP_VERSION: ${{ steps.set-version.outputs._PKG_VERSION }}
VITE_APP_CLUSTER: ${{ vars.REACT_APP_CLUSTER }}
VITE_APP_WORMHOLE_CONNECT_VERSION: ${{ inputs.connect-branch }}
VITE_APP_JS_WC_INTEGRITY_SHA_384: ${{ steps.wormhole-connect.outputs._JS_SHA_384 }}
VITE_APP_CSS_WC_INTEGRITY_SHA_384: ${{ steps.wormhole-connect.outputs._CSS_SHA_384 }}
VITE_APP_WALLET_CONNECT_PROJECT_ID: ${{ secrets.REACT_APP_WALLET_CONNECT_PROJECT_ID }}
Expand Down Expand Up @@ -290,6 +291,7 @@ jobs:
PUBLIC_URL: "${{ inputs.public-url }}"
VITE_APP_VERSION: ${{ steps.set-version.outputs._PKG_VERSION }}
VITE_APP_CLUSTER: ${{ vars.REACT_APP_CLUSTER }}
VITE_APP_WORMHOLE_CONNECT_VERSION: ${{ inputs.connect-branch }}
VITE_APP_JS_WC_INTEGRITY_SHA_384: ${{ steps.wormhole-connect.outputs._JS_SHA_384 }}
VITE_APP_CSS_WC_INTEGRITY_SHA_384: ${{ steps.wormhole-connect.outputs._CSS_SHA_384 }}
VITE_APP_WALLET_CONNECT_PROJECT_ID: ${{ secrets.REACT_APP_WALLET_CONNECT_PROJECT_ID }}
Expand Down
4 changes: 2 additions & 2 deletions apps/connect/src/components/ConnectLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function ConnectLoader({ config }: WormholeLoaderProps) {

useEffect(() => {
const script = document.createElement("script");
script.src = `assets/wormhole-connect/main.js?id=${VITE_APP_JS_WC_INTEGRITY_SHA_384}`;
script.src = `assets/${wcVersion}/main.js`;
script.type = "module";
if (VITE_APP_JS_WC_INTEGRITY_SHA_384) {
script.integrity = `sha384-${VITE_APP_JS_WC_INTEGRITY_SHA_384}`;
Expand All @@ -32,7 +32,7 @@ export default function ConnectLoader({ config }: WormholeLoaderProps) {
script.onload = () => setLoading(false);
const link = document.createElement("link");
link.rel = "stylesheet";
link.href = `assets/wormhole-connect/main.css?id=${VITE_APP_CSS_WC_INTEGRITY_SHA_384}`;
link.href = `assets/${wcVersion}/main.css`;
if (VITE_APP_CSS_WC_INTEGRITY_SHA_384) {
link.integrity = `sha384-${VITE_APP_CSS_WC_INTEGRITY_SHA_384}`;
}
Expand Down
1 change: 1 addition & 0 deletions apps/connect/src/vite-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ declare global {
declare const wormholeConnectConfig: WormholeConnectConfig;
declare const navBar: NavLink[];
declare const redirects: Redirect;
declare const wcVersion: string;
}
12 changes: 8 additions & 4 deletions apps/connect/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import { viteStaticCopy } from 'vite-plugin-static-copy'

const { VITE_APP_WORMHOLE_CONNECT_VERSION = "latest" } = process.env;
const WORMHOLE_CONNECT_TAG = `wc-${VITE_APP_WORMHOLE_CONNECT_VERSION}-${Date.now()}`;

const rpcs = (chains: string[], template: (chain: string) => string) => chains.map((chain: string) => ({ [chain]: template(chain) })).reduce((acc, cur) => ({ ...acc, ...cur }), {});
const asRpcHost = (chain: string) => `https://and76cjzpa.execute-api.us-east-2.amazonaws.com/${chain}/`;
const chains = [
Expand Down Expand Up @@ -49,6 +52,7 @@ export default defineConfig({
]
},
define: {
wcVersion: WORMHOLE_CONNECT_TAG,
redirects: {},
wormholeConnectConfig: {
walletConnectProjectId: process.env.VITE_APP_WALLET_CONNECT_PROJECT_ID || '',
Expand All @@ -73,19 +77,19 @@ export default defineConfig({
targets: [
{
src: 'node_modules/@wormhole-foundation/wormhole-connect/dist/*.js',
dest: 'assets/wormhole-connect/'
dest: `assets/${WORMHOLE_CONNECT_TAG}/`
},
{
src: 'node_modules/@wormhole-foundation/wormhole-connect/dist/*.css',
dest: 'assets/wormhole-connect/'
dest: `assets/${WORMHOLE_CONNECT_TAG}/`
},
{
src: 'node_modules/@wormhole-foundation/wormhole-connect/dist/assets/*.js',
dest: 'assets/wormhole-connect/assets'
dest: `assets/${WORMHOLE_CONNECT_TAG}/assets/`
},
{
src: 'node_modules/@wormhole-foundation/wormhole-connect/dist/assets/*.css',
dest: 'assets/wormhole-connect/assets'
dest: `assets/${WORMHOLE_CONNECT_TAG}/assets/`
}
]
})
Expand Down

0 comments on commit da3941d

Please sign in to comment.