Skip to content

Commit

Permalink
feat: add transformIndexHtml
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaochenchen-igg-com committed Feb 15, 2022
1 parent ab36fba commit 1858849
Show file tree
Hide file tree
Showing 9 changed files with 214 additions and 112 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ The following show the default values of the configuration
```ts
dynamicBase({
// dynamic public path var string, default window.__dynamic_base__
publicPath: 'window.__dynamic_base__'
publicPath: 'window.__dynamic_base__',
// transformIndexHtml, default false, maybe change default true
transformIndexHtml: false
})
```

3 changes: 3 additions & 0 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
<script>
window.__dynamic_base__ = 'http:https://localhost:8090'
</script>
</head>

<body>
Expand Down
2 changes: 1 addition & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@vitejs/plugin-vue": "^2.0.0",
"typescript": "^4.4.4",
"vite": "^2.7.2",
"vite-plugin-dynamic-base": "0.0.3",
"vite-plugin-dynamic-base": "0.1.0",
"vue-tsc": "^0.29.8"
}
}
8 changes: 4 additions & 4 deletions examples/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion examples/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { dynamicBase } from 'vite-plugin-dynamic-base'
// import { dynamicBase } from '../dist/index'

// https://vitejs.dev/config/
export default defineConfig({
// base: 'a/b',
plugins: [
vue(),
dynamicBase()
dynamicBase({ transformIndexHtml: true })
],
build: {
// assetsDir: 'assets/a/b'
Expand Down
3 changes: 2 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export interface Options {
publicPath?: string
publicPath?: string,
transformIndexHtml?: boolean
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vite-plugin-dynamic-base",
"version": "0.0.3",
"version": "0.1.0",
"description": "Resolve all resource files dynamic publicPath, like Webpack's __webpack_public_path__",
"main": "dist/index.js",
"scripts": {
Expand All @@ -22,6 +22,7 @@
"homepage": "https://github.com/chenxch/vite-plugin-dynamic-base",
"devDependencies": {
"@types/node": "^16.0.0",
"node-html-parser": "^5.2.0",
"vite": "^2.4.0"
},
"keywords": [
Expand Down
Loading

0 comments on commit 1858849

Please sign in to comment.