Last active
March 10, 2023 05:10
-
-
Save iTonyYo/09f945f305e17d15e5ee3278779ef6c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { type Plugin, type UserConfig } from 'vite'; | |
export default function myPlugin(): Plugin { | |
return { | |
enforce: 'post', | |
apply: 'build', | |
name: 'blabla', | |
/* | |
config.build.rollupOptions.input): { | |
Quotation: '/Users/iyowei/Development/szfiu/buffett/src/apps/Quotation/index.html', | |
Us: '/Users/iyowei/Development/szfiu/buffett/src/apps/Us/index.html' | |
} | |
*/ | |
config(config: UserConfig) { | |
config.build = config.build || {}; | |
config.build.rollupOptions = config.build.rollupOptions || {}; | |
// console.log(config); | |
// console.log(config.plugins); | |
// console.log(config.build.rollupOptions.input); | |
}, | |
transformIndexHtml() {}, | |
configResolved() {}, | |
transform(code, id) { | |
if (!id.includes('node_modules')) { | |
/** | |
console.log(id); | |
/Users/iyowei/Development/szfiu/buffett/src/apps/Us/index.html | |
/Users/iyowei/Development/szfiu/buffett/src/apps/Quotation/index.html | |
transforming (1) src/apps/Us/index.htmlvite/modulepreload-polyfill | |
/Users/iyowei/Development/szfiu/buffett/src/apps/Us/main.tsx | |
/Users/iyowei/Development/szfiu/buffett/src/apps/Quotation/main.tsx | |
transforming (6) node_modules/.pnpm/[email protected]_zula6vjvt3wdocc4mwcxqa6nzi/node_modules/click-to-react-component/src/index.jsvite/preload-helper | |
/Users/iyowei/Development/szfiu/buffett/src/components/QuotationUsEtf/index.ts | |
/Users/iyowei/Development/szfiu/buffett/src/components/QuotationProtocol/index.ts | |
/Users/iyowei/Development/szfiu/buffett/src/components/QuotationMarket/index.ts | |
/Users/iyowei/Development/szfiu/buffett/src/components/QuotationLogin/index.ts | |
/Users/iyowei/Development/szfiu/buffett/src/components/QuotationSearch/index.ts | |
/Users/iyowei/Development/szfiu/buffett/src/components/QuotationEtfList/index.ts | |
/Users/iyowei/Development/szfiu/buffett/src/components/QuotationPlans/index.ts | |
/Users/iyowei/Development/szfiu/buffett/src/components/QuotationPayment/index.ts | |
/Users/iyowei/Development/szfiu/buffett/src/components/QuotationRoot/index.ts | |
/Users/iyowei/Development/szfiu/buffett/src/components/QuotationDetails/index.ts | |
*/ | |
// console.log(id); | |
} | |
}, | |
generateBundle(aa, bundle) { | |
/* | |
console.log('>', bundle); | |
'assets/Us-5a186559.js': { | |
exports: [], | |
facadeModuleId: '/Users/iyowei/Development/szfiu/buffett/src/apps/Us/index.html', | |
isDynamicEntry: false, | |
isEntry: true, | |
isImplicitEntry: false, | |
moduleIds: [ | |
'/Users/iyowei/Development/szfiu/buffett/src/assets/image/[email protected]', | |
'/Users/iyowei/Development/szfiu/buffett/src/assets/image/[email protected]', | |
'/Users/iyowei/Development/szfiu/buffett/src/assets/image/[email protected]', | |
'/Users/iyowei/Development/szfiu/buffett/src/assets/image/yes.svg', | |
'/Users/iyowei/Development/szfiu/buffett/src/apps/Us/App.tsx', | |
'/Users/iyowei/Development/szfiu/buffett/src/apps/Us/main.tsx', | |
'/Users/iyowei/Development/szfiu/buffett/src/apps/Us/index.html' | |
], | |
name: 'Us', | |
type: 'chunk', | |
dynamicImports: [], | |
fileName: 'assets/Us-5a186559.js', | |
implicitlyLoadedBefore: [], | |
importedBindings: { 'assets/FlexBox-e8d9d2c4.js': [Array] }, | |
imports: [ 'assets/FlexBox-e8d9d2c4.js' ], | |
modules: [Object: null prototype] { | |
'/Users/iyowei/Development/szfiu/buffett/src/assets/image/[email protected]': [Object], | |
'/Users/iyowei/Development/szfiu/buffett/src/assets/image/[email protected]': [Object], | |
'/Users/iyowei/Development/szfiu/buffett/src/assets/image/[email protected]': [Object], | |
'/Users/iyowei/Development/szfiu/buffett/src/assets/image/yes.svg': [Object], | |
'/Users/iyowei/Development/szfiu/buffett/src/apps/Us/App.tsx': [Object], | |
'/Users/iyowei/Development/szfiu/buffett/src/apps/Us/main.tsx': [Object], | |
'/Users/iyowei/Development/szfiu/buffett/src/apps/Us/index.html': [Object] | |
}, | |
referencedFiles: [], | |
viteMetadata: { importedAssets: [Set], importedCss: Set(0) {} }, | |
code: 'import{j as e,F as a,c,e as o,C as i}from"./FlexBox-e8d9d2c4.js";const p=""+new URL("[email protected]",import.meta.url).href,m=""+new URL("[email protected]",import.meta.url).href,d=""+new URL("[email protected]",import.meta.url).href,l=""+new URL("yes-16be297a.svg",import.meta.url).href;function t({children:r}){return e.jsx("h1",{className:"text-36px font-extrabold relative px-20px mt-60px mb-30px before:-z-1 before:opacity-60 before:bg-gradient-to-r before:from-[#8465FE] before:to-[#FDFDFF] before:absolute before:content-DEFAULT before:bottom-0 before:left-20px before:w-223px before:h-20px before:bg-rose-300",children:r})}function s({children:r,className:n="",overlayClassName:x=""}){return e.jsxs(a,{className:c("relative",n),children:[e.jsx("div",{className:c("absolute z-10 top-0 left-0 w-full h-full",x)}),e.jsx(a,{className:"absolute z-20 top-0 left-0 w-full h-full",children:r})]})}function g(){return e.jsxs(e.Fragment,{children:[e.jsx(t,{children:"美股行情对比"}),e.jsxs(a,{className:"rounded-22px overflow-hidden text-center children:flex-1 gap-1px w-711px my-0 mx-auto",children:[e.jsxs(a,{className:" children:h-80px children:w-full",direction:"col",children:[e.jsx(s,{overlayClassName:"bg-[#B29FFE] opacity-30",children:" "}),e.jsx(s,{overlayClassName:"bg-[#E1DBFF] opacity-30",children:"买卖盘口"}),e.jsx(s,{overlayClassName:"bg-[#E1DBFF] opacity-30",children:"逐笔成交"}),e.jsx(s,{overlayClassName:"bg-[#E1DBFF] opacity-30",children:"报价数据"}),e.jsx(s,{overlayClassName:"bg-[#E1DBFF] opacity-30",children:"档位数据"}),e.jsx(s,{overlayClassName:"bg-[#E1DBFF] opacity-30",children:"OTC市场"}),e.jsx(s,{overlayClassName:"bg-[#E1DBFF] opacity-30",children:"盘前数据"}),e.jsx(s,{overlayClassName:"bg-[#E1DBFF] opacity-30",children:"盘后数据"})]}),e.jsxs(a,{className:"children:h-80px children:w-full",direction:"col",children:[e.jsx(s,{overlayClassName:"bg-[#B29FFE] opacity-30",children:"lv0"}),e.jsx(s,{overlayClassName:"bg-[#E1DBFF] opacity-40",className:"text-[#778691]",children:"X无"}),e.jsx(s,{overlayClassName:"bg-[#E1DBFF] opacity-40",className:"text-[#778691]",children:"X无"}),e.jsx(s,{overlayClassName:"bg-[#E1DBFF] opacity-40",className:"text-[#778691]",children:"部分"}),e.jsx(s,{overlayClassName:"bg-[#E1DBFF] opacity-40",className:"text-[#778691]",children:"X无"}),e.jsx(s,{overlayClassName:"bg-[#E1DBFF] opacity-40",className:"text-[#778691]",children:"X无"}),e.jsx(s,{overlayClassName:"bg-[#E1DBFF] opacity-40",className:"text-[#778691]",children:"X无"}),e.jsx(s,{overlayClassName:"bg-[#E1DBFF] opacity-40",className:"text-[#778691]",children:"X无"})]}),e.jsxs(a,{className:"children:h-80px children:w-full",direction:"col",children:[e.jsx(s,{overlayClassName:"bg-[#B29FFE]",children:"lv1"}),e.jsx(s,{overlayClassName:"bg-[#E1DBFF]",children:e.jsxs(a,{className:"gap-10px",children:[e.jsx("i",{className:"w-19px h-15px bg-cover bg-center bg-no-repeat",style:{backgroundImage:`url(${l})`}}),"实时"]})}),e.jsx(s,{overlayClassName:"bg-[#E1DBFF]",children:e.jsxs(a,{className:"gap-10px",children:[e.jsx("i",{className:"w-19px h-15px bg-cover bg-center bg-no-repeat",style:{backgroundImage:`url(${l})`}}),"实时"]})}),e.jsx(s,{overlayClassName:"bg-[#E1DBFF]",children:"全部"}),e.jsx(s,{overlayClassName:"bg-[#E1DBFF]",children:"买卖 1 档"}),e.jsx(s,{overlayClassName:"bg-[#E1DBFF]",children:e.jsxs(a,{className:"gap-10px",children:[e.jsx("i",{className:"w-19px h-15px bg-cover bg-center bg-no-repeat",style:{backgroundImage:`url(${l})`}}),"实时"]})}),e.jsx(s,{overlayClassName:"bg-[#E1DBFF]",children:e.jsxs(a,{className:"gap-10px",children:[e.jsx("i",{className:"w-19px h-15px bg-cover bg-center bg-no-repeat",style:{backgroundImage:`url(${l})`}}),"实时"]})}),e.jsx(s,{overlayClassName:"bg-[#E1DBFF]",children:e.jsxs(a,{className:"gap-10px",children:[e.jsx("i",{className:"w-19px h-15px bg-cover bg-center bg-no-repeat",style:{backgroundImage:`url(${l})`}}),"实时"]})})]})]})]})}function b(){return e.jsxs(e.Fragment,{children:[e.jsx(t,{children:"逐笔成交明细"}),e.jsx("p",{className:"font-light text-26px text-[#778691] px-20px",children:"逐笔精确反映盘中交易变动,洞悉资金流入流出意图"}),e.jsx("div",{className:"bg-rose-100 w-710px h-476px my-0 mx-auto mt-20px mb-30px rounded-22px bg-cover bg-center bg-no-repeat",style:{backgroundImage:`url(${d})`}})]})}function h(){return e.jsxs(e.Fragment,{children:[e.jsx(t,{children:"一档买卖委托"}),e.jsx("p",{className:"font-light text-26px text-[#778691] px-20px",children:"逐笔精确反映盘中交易变动,洞悉资金流入流出意图"}),e.jsx("div",{className:"bg-rose-100 w-710px h-206px my-0 mx-auto mt-20px mb-30px rounded-22px bg-cover bg-center bg-no-repeat",style:{backgroundImage:`url(${m})`}})]})}function j(){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bg-rose-100 w-710px h-310px my-0 mx-auto mt-20px mb-30px rounded-22px bg-cover bg-center bg-no-repeat",style:{backgroundImage:`url(${p})`}}),e.jsxs("div",{className:"children:shadow-b-0.5px",children:[e.jsxs(a,{justify:"between",className:"py-25px px-20px",children:[e.jsx("span",{className:"font-light text-[#778691]",children:"适用终端"}),e.jsx("span",{className:"font-light text-[#222]",children:"APP、PC、WEB"})]}),e.jsxs(a,{justify:"between",className:"py-25px px-20px",children:[e.jsx("span",{className:"font-light text-[#778691]",children:"适用地区"}),e.jsx("span",{className:"font-light text-[#222]",children:"不限地区"})]})]}),e.jsx(g,{}),e.jsx(b,{}),e.jsx(h,{}),e.jsxs("div",{className:"pt-10px pb-200px px-20px text-[#778691] text-24px font-light leading-relaxed",children:[e.jsx("p",{children:"温馨提示"}),e.jsxs("p",{children:["FIU暂时仅支持非专业投资者 (Non-ProfessionalSubscriber) 申请美股Lv1高级行情,应交易所要求,申请美股Lv1高级行情时需填写",e.jsx("span",{className:"text-[#FF9933]",children:"非专业用户资格认证信息"}),"。"]}),e.jsx("p",{children:"应交易所要求,行情购买后仅授权一个设备;多台设备同时登陆时,仅新登录设备生效,旧设备页面会有抢占行情提示。"})]})]})}o(document.getElementById("root")).render(e.jsxs(e.Fragment,{children:[e.jsx(j,{}),e.jsx(i,{})]}));\n', | |
map: null | |
} | |
*/ | |
console.log('>', bundle); | |
}, | |
closeBundle() { | |
// console.log(arguments); | |
}, | |
async buildEnd(error) { | |
if (error) | |
throw error | |
}, | |
}; | |
} | |
// TODO: 什么时机可以获取到被贴上指纹码的路径 dist/h5/assets/index-22cb297b.js | |
/* | |
目前项目里使用到的插件, | |
[ | |
{ | |
name: 'transform-file', | |
config: [Function: config], | |
configResolved: [Function: configResolved], | |
transform: [Function: transform], | |
closeBundle: [Function: closeBundle] | |
}, | |
{ | |
name: 'vite-plugin-mpa', | |
enforce: 'pre', | |
config: [Function: config], | |
configureServer: [Function: configureServer], | |
closeBundle: [Function: closeBundle] | |
}, | |
[ | |
{ | |
name: 'vite:react-swc', | |
apply: 'serve', | |
config: [Function: config], | |
resolveId: [Function: resolveId], | |
load: [Function: load], | |
transformIndexHtml: [Function: transformIndexHtml], | |
transform: [AsyncFunction: transform] | |
}, | |
{ | |
name: 'vite:react-swc', | |
apply: 'build', | |
config: [Function: config] | |
} | |
], | |
[ | |
{ | |
name: 'vite-plugin-windicss:alias', | |
enforce: 'pre', | |
configResolved: [Function: configResolved], | |
transform: [AsyncFunction: transform] | |
}, | |
{ | |
name: 'vite-plugin-windicss:groups', | |
enforce: 'pre', | |
transform: [AsyncFunction: transform] | |
}, | |
{ name: 'vite-plugin-windicss', api: [Getter] }, | |
{ | |
name: 'vite-plugin-windicss:entry', | |
enforce: 'post', | |
configureServer: [Function: configureServer], | |
configResolved: [AsyncFunction: configResolved], | |
resolveId: [Function: resolveId], | |
load: [AsyncFunction: load], | |
watchChange: [AsyncFunction: watchChange] | |
}, | |
{ | |
name: 'vite-plugin-windicss:hmr', | |
apply: 'serve', | |
enforce: 'pre', | |
configureServer: [AsyncFunction: configureServer], | |
handleHotUpdate: [AsyncFunction: handleHotUpdate] | |
}, | |
{ | |
name: 'vite-plugin-windicss:css', | |
transform: [AsyncFunction: transform] | |
}, | |
{ name: 'vite-plugin-windicss:css:svelte', api: [Object] }, | |
{ | |
name: 'vite-plugin-windicss:devtools', | |
configResolved: [Function: configResolved], | |
configureServer: [Function: configureServer], | |
resolveId: [Function: resolveId], | |
load: [AsyncFunction: load] | |
} | |
], | |
[ | |
{ | |
name: 'vite-plugin-pwa', | |
enforce: 'pre', | |
config: [Function: config], | |
configResolved: [AsyncFunction: configResolved], | |
resolveId: [Function: resolveId], | |
load: [Function: load], | |
api: [Object] | |
}, | |
{ | |
name: 'vite-plugin-pwa:info', | |
enforce: 'post', | |
resolveId: [Function: resolveId], | |
load: [Function: load] | |
}, | |
{ | |
name: 'vite-plugin-pwa:build', | |
enforce: 'post', | |
apply: 'build', | |
transformIndexHtml: [Object], | |
generateBundle: [Function: generateBundle], | |
closeBundle: [Object], | |
buildEnd: [AsyncFunction: buildEnd] | |
}, | |
{ | |
name: 'vite-plugin-pwa:dev-sw', | |
apply: 'serve', | |
transformIndexHtml: [Object], | |
configureServer: [Function: configureServer], | |
resolveId: [Function: resolveId], | |
load: [AsyncFunction: load] | |
} | |
], | |
{ | |
name: 'visualizer', | |
generateBundle: [AsyncFunction: generateBundle] | |
} | |
] | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment