Skip to content

Commit

Permalink
feat: pwa,base mark
Browse files Browse the repository at this point in the history
  • Loading branch information
chenxch committed May 1, 2022
1 parent 0dfc637 commit 650ce76
Show file tree
Hide file tree
Showing 17 changed files with 3,756 additions and 400 deletions.
13 changes: 0 additions & 13 deletions CHANGELOG.en-US.md

This file was deleted.

32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## Changelog

### 0.4.0

_2022-05-01_

#### Features

- compatible `vite-plugin-pwa`
- base mark

#### Bug fixes

- Multi-level cdn reference resource path fix

#### Refactors

- Replace the matching scheme and use the base attribute as a marker bit
- Code structure adjustment, introduction of asynchronous processing


### 0.3.0

_2022-04-23_

#### Features

- setup simple unit tests with `vitest`. (#5 by @zhoujinfu)

#### Bug fixes

- import.env.LEGACY cause undefined errors with vite config `define`. (#5 by @zhoujinfu)
32 changes: 32 additions & 0 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## Changelog

### 0.4.0

_2022-05-01_

#### 新特性

- 兼容`vite-plugin-pwa`
- base标记

#### Bug 修复

- 多层级cdn引用资源路径修复

#### 重构

- 更换匹配方案,使用base属性作为标记位
- 代码结构调整,引入异步处理


### 0.3.0

_2022-04-23_

#### 新特性

- 添加简单的单元测试 `vitest`. (#5 by @zhoujinfu)

#### Bug 修复

- import.env.LEGACY 未定义的错误. (#5 by @zhoujinfu)
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,46 @@ npm i vite-plugin-dynamic-base -D

## Changelog

### 0.3.0
### 0.4.0

_2022-04-23_
_2022-05-01_

#### Features

- setup simple unit tests with `vitest`. (#5 by @zhoujinfu)
- compatible `vite-plugin-pwa`
- base mark

#### Bug fixes

- import.env.LEGACY cause undefined errors with vite config `define`. (#5 by @zhoujinfu)
- Multi-level cdn reference resource path fix

#### Refactors

- Replace the matching scheme and use the base attribute as a marker bit
- Code structure adjustment, introduction of asynchronous processing

[Changelogs](./CHANGELOG.md)


## Build Mode

- [x] es
- [x] system

## Compatible plugins

- [x] [@vitejs/plugin-legacy](https://www.npmjs.com/package/@vitejs/plugin-legacy)
- [x] [vite-plugin-pwa](https://www.npmjs.com/package/vite-plugin-pwa)

## Usage

```ts
// 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 */ }),
],
Expand Down
28 changes: 22 additions & 6 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,46 @@ npm i vite-plugin-dynamic-base -D

## 变更日志

### 0.3.0
### 0.4.0

_2022-04-23_
_2022-05-01_

#### 新特性

- 添加简单的单元测试 `vitest`. (#5 by @zhoujinfu)
- 兼容`vite-plugin-pwa`
- base标记

#### Bug fixes
#### Bug 修复

- import.env.LEGACY 未定义的错误. (#5 by @zhoujinfu)
- 多层级cdn引用资源路径修复

#### 重构

- 更换匹配方案,使用base属性作为标记位
- 代码结构调整,引入异步处理

[变更日志](./CHANGELOG.zh-CN.md)

## 编译模式

- [x] es
- [x] system

## 兼容插件

- [x] [@vitejs/plugin-legacy](https://www.npmjs.com/package/@vitejs/plugin-legacy)
- [x] [vite-plugin-pwa](https://www.npmjs.com/package/vite-plugin-pwa)


## 使用

```ts
// vite.config.ts
import { dynamicBase } from 'vite-plugin-dynamic-base'

export default defineConfig({
export default defineConfig({
// base: "/",
base: process.env.NODE_ENV === "production" ? "/__dynamic_base__/" : "/",
plugins: [
dynamicBase({ /* options */ }),
],
Expand Down
2 changes: 1 addition & 1 deletion examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
<script>
window.__dynamic_base__ = 'http:https://localhost:8090'
window.__dynamic_base__ = 'http:https://localhost:8090/base'
</script>
</head>

Expand Down
3 changes: 2 additions & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"@vitejs/plugin-vue": "^2.0.0",
"typescript": "^4.4.4",
"vite": "^2.7.2",
"vite-plugin-dynamic-base": "0.1.0",
"vite-plugin-dynamic-base": "^0.3.0",
"vite-plugin-pwa": "^0.12.0",
"vue-tsc": "^0.29.8"
}
}
Loading

0 comments on commit 650ce76

Please sign in to comment.