Skip to content

Commit

Permalink
docs: minify
Browse files Browse the repository at this point in the history
  • Loading branch information
lisonge committed Sep 21, 2023
1 parent 1492678 commit d17f9b7
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,16 @@ there is the following cdn to use, full detail see [cdn.ts](/packages/vite-plugi

if you want use other cdn, you can see [external-scripts](https://greasyfork.org/help/external-scripts)

## Minify

because of the [code-rules](https://greasyfork.org/en/help/code-rules) of greasyfork

> Code posted to Greasy Fork must not be obfuscated or minified
so plugin will change the default value of [viteConfig.build.minify](https://cn.vitejs.dev/config/build-options.html#build-minify) to `false`

if you want to enable minify, just set `viteConfig.build.minify=true`

## GM_api usage

### ESM usage
Expand Down
31 changes: 31 additions & 0 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,27 @@ export type MonkeyOption = {
};
```

## 排除依赖的CDN工具

```ts
import { defineConfig } from 'vite';
import monkey, { cdn } from 'vite-plugin-monkey';
export default defineConfig({
plugins: [
monkey({
build: {
externalGlobals: {
react: cdn.jsdelivr('React', 'umd/react.production.min.js'),
},
externalResource: {
'element-plus/dist/index.css': cdn.jsdelivr(),
},
},
}),
],
});
```

有以下 cdn 可使用,详情见 [cdn.ts](/packages/vite-plugin-monkey/src/node/cdn.ts)

- [jsdelivr](https://www.jsdelivr.com/)
Expand All @@ -319,6 +340,16 @@ export type MonkeyOption = {

如果你想使用其他 cdn,请查看 [external-scripts](https://greasyfork.org/zh-CN/help/external-scripts)

## 压缩混淆

由于 greasyfork 的 [代码规则](https://greasyfork.org/zh-CN/help/code-rules)

> 提交到 Greasy Fork 的代码不得混淆或最小化
因此插件将 [viteConfig.build.minify](https://cn.vitejs.dev/config/build-options.html#build-minify) 的默认值更改为 `false`

如果你想启用压缩混淆, 只需要手动设置 `viteConfig.build.minify=true`

## GM_api 用法

### ESM 用法
Expand Down

0 comments on commit d17f9b7

Please sign in to comment.