From b0d751cf80f4432098d60cf97dfd754ae61eb68a Mon Sep 17 00:00:00 2001 From: CarlLiu2023 <129018164+CarlLiu2023@users.noreply.github.com> Date: Fri, 8 Sep 2023 16:29:39 +0800 Subject: [PATCH] Revert "feat: 1. absolute path 2.build entryFileNames index 3.add headless script name buyerPortal" This reverts commit 7ad00083341710bcadcb5a29b7444d6db3a13567. --- apps/storefront/src/buyerPortal.ts | 81 ------------------------------ apps/storefront/vite.config.ts | 44 ---------------- 2 files changed, 125 deletions(-) delete mode 100644 apps/storefront/src/buyerPortal.ts diff --git a/apps/storefront/src/buyerPortal.ts b/apps/storefront/src/buyerPortal.ts deleted file mode 100644 index 81efabeb4..000000000 --- a/apps/storefront/src/buyerPortal.ts +++ /dev/null @@ -1,81 +0,0 @@ -// const str = ' - -// -// -// ' - -function init() { - const insertScript = (scriptString: string) => { - // const scriptElement = document.createElement('script'); - // scriptElement.innerHTML = scriptString; - - // const {body} = document; - - // body.appendChild(scriptElement); - - document.body.innerHTML += scriptString - } - async function getScriptContent(originurl: string) { - console.log(originurl) - const xxx = ` - - ` - - insertScript(xxx) - // const queryParams = new URLSearchParams({ - // url: originurl, - // }); - - // const url = `https://api.example.com/data?${queryParams}`; - // fetch(url).then(response => { - // if (!response.ok) { - // throw new Error('Network response was not ok'); - // } - // return response.json(); - // }) - // .then(data => { - // console.log(data); - - // insertScript(data) - // }) - // .catch(error => { - // console.error('There was a problem with the fetch operation:', error); - // }); - } - - async function analyzeScript() { - try { - const { origin } = window.location - - await getScriptContent(origin) - } catch (error) { - console.error('Interface error') - } - } - - analyzeScript() -} - -init() - -export {} diff --git a/apps/storefront/vite.config.ts b/apps/storefront/vite.config.ts index 2b7e19367..933e4b489 100644 --- a/apps/storefront/vite.config.ts +++ b/apps/storefront/vite.config.ts @@ -6,15 +6,6 @@ import path from 'path' // eslint-disable-line import { visualizer } from 'rollup-plugin-visualizer' import { defineConfig, loadEnv } from 'vite' -interface AssetsAbsolutePathProps { - [key: string]: string -} - -const assetsAbsolutePath: AssetsAbsolutePathProps = { - staging: 'https://cdn.bundleb2b.net/b2b/staging/storefront/assets/', - production: 'https://cdn.bundleb2b.net/b2b/production/storefront/assets/', -} - export default defineConfig(({ mode }) => { const env = loadEnv(mode, process.cwd()) return { @@ -24,23 +15,6 @@ export default defineConfig(({ mode }) => { }), react(), ], - experimental: { - renderBuiltUrl( - filename: string, - { - type, - }: { - type: 'public' | 'asset' - } - ) { - if (type === 'asset') { - const name = filename.split('assets/')[1] - return `${assetsAbsolutePath[mode]}${name}` - } - - return undefined - }, - }, server: { port: 3001, proxy: { @@ -64,24 +38,6 @@ export default defineConfig(({ mode }) => { build: { minify: true, rollupOptions: { - input: { - index: 'src/main.ts', - buyerPortal: 'src/buyerPortal.ts', - }, - output: { - entryFileNames(info) { - const { name } = info - return name.includes('buyerPortal') - ? '[name].js' - : '[name].[hash].js' - }, - }, - onwarn(warning, warn) { - if (warning.code === 'MODULE_LEVEL_DIRECTIVE') { - return - } - warn(warning) - }, manualChunks: { intl: ['react-intl'], redux: ['react-redux'],