English | 简体中文
- 🦾 Resolve all resource files dynamic publicPath, like Webpack's
__webpack_public_path__
.
npm i vite-plugin-dynamic-base -D
2022-05-01
- compatible
vite-plugin-pwa
- base mark (From the original automatic search and replacement to using base as the marker bit to replace, this is for more accurate processing, and in some scenarios in pwa, you need to use base as the marker bit)
- Multi-level cdn reference resource path fix
- Replace the matching scheme and use the base attribute as a marker bit
- Code structure adjustment, introduction of asynchronous processing
- es
- system
// vite.config.ts
import { dynamicBase } from 'vite-plugin-dynamic-base'
export default defineConfig({
// base: "/",
base: process.env.NODE_ENV === "production" ? "/__dynamic_base__/" : "/",
plugins: [
dynamicBase({ /* options */ }),
],
})
The following show the default values of the configuration
dynamicBase({
// dynamic public path var string, default window.__dynamic_base__
publicPath: 'window.__dynamic_base__',
// dynamic load resources on index.html, default false. maybe change default true
transformIndexHtml: false
})
- Exploring the feasibility of using SWC to transform the AST for processing