Skip to content

Latest commit

 

History

History
78 lines (57 loc) · 2.25 KB

README.zh-CN.md

File metadata and controls

78 lines (57 loc) · 2.25 KB

vite-plugin-dynamic-base

Version Languages License Star Download

English | 简体中文

  • 🦾 解析所有资源文件动态路径(多cdn切换), 类似 Webpack 的 __webpack_public_path__.

安装

npm i vite-plugin-dynamic-base -D

变更日志

变更日志

编译模式

  • 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 */ }),
  ],
})

配置

以下显示配置的默认值

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
  // provide conversion configuration parameters. by 1.1.0
  // transformIndexHtmlConfig: { insertBodyAfter: false }
})