Skip to content

Commit

Permalink
Merge pull request #1 from chengpeiquan/develop
Browse files Browse the repository at this point in the history
Release v0.1.1
  • Loading branch information
chengpeiquan authored Feb 23, 2021
2 parents fa8ec5d + b230860 commit 23a8cc4
Show file tree
Hide file tree
Showing 19 changed files with 2,890 additions and 1 deletion.
18 changes: 18 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"presets": [
[
"@babel/preset-env",
{
"modules": false,
"targets": {
"browsers": "> 1%, IE 11, not op_mini all, not dead"
},
"useBuiltIns": "usage",
"corejs": 2
}
]
],
"plugins": [
"@babel/plugin-proposal-class-properties"
]
}
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# http://editorconfig.org
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 80
trim_trailing_whitespace = true

[*.md]
max_line_length = 0
trim_trailing_whitespace = false
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: https://git.io/Sponsor
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
149 changes: 148 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,148 @@
# vite-plugin-banner
<p align='center'>
<img src="https://cdn.jsdelivr.net/gh/chengpeiquan/assets-storage/img/2021/02/20210224005014.png" alt="vite-plugin-banner" />
</p>

<p align='center'>
<a href='https://www.npmjs.com/package/vite-plugin-banner'>
<img src="https://img.shields.io/npm/v/vite-plugin-banner?color=56b7ff&label=npm" />
</a>
</p>
<br>
<br>

English | [简体中文](https://github.com/chengpeiquan/vite-plugin-banner/blob/main/README.zh-CN.md)

## Features

Adds a banner to the top of each generated chunk.

## Usage

> ℹ️ **Only support for Vite 2.**
### Install

Install the package from npm (or yarn).

```bash
npm install --save-dev vite-plugin-banner
```

### Basic usage

Add it to `vite.config.ts`

```ts
// vite.config.ts
import Banner from 'vite-plugin-banner'
// Other dependencies...

export default defineConfig({
plugins: [
Banner('This is the Banner content.'),
]
})
```

When you run `npm run build` on your project, In the `dist` folder(Or the [build.outDir](https://vitejs.dev/config/#build-outdir) in `vite.config.ts` you configured), Except for `vendor` files, all `js` and `css` files will add a banner to the top.

e.g. in `app.b3a7772e.js`:

```js
/* This is the Banner content. */
var e=Object.assign;import{M as t,d as a,u as r,c......
```

### Advanced usage

Of course, the most ideal banner is related to your package information.

First, You need to update your `package.json` like this, For example, it contains such field content:

```json
// package.json
{
"name": "chengpeiquan.com",
"version": "0.1.0",
"description": "My personal website, technology stack based on Vue.js 3.0, and Vite 2.0, use Server Side Generation.",
"author": "chengpeiquan",
"homepage": "https://chengpeiquan.com/"
}
```

Then, import the `package.json` into `vite.config.ts`, update the banner like this:

```ts
// vite.config.ts
import pkg from './package.json'
// Other dependencies...

export default defineConfig({
plugins: [
Banner(`/**\n * name: ${pkg.name}\n * version: v${pkg.version}\n * description: v${pkg.description}\n * author: ${pkg.author}\n * homepage: ${pkg.homepage}\n */`),
]
})
```

Run `npm run build`, you can see the banner become more detailed.

e.g. in `app.b3a7772e.js`:

```js
/**
* name: chengpeiquan.com
* version: v0.1.0
* description: vMy personal website, technology stack based on Vue.js 3.0, and Vite 2.0, use Server Side Generation.
* author: chengpeiquan
* homepage: https://chengpeiquan.com/
*/
var e=Object.assign;import{M as t,d as a,u as r,c......
```

### Fun usage

If you want to make some banners that show your personality, you can make some interesting content from some online generators.

Such as:

- [http://www.network-science.de/ascii/](http://www.network-science.de/ascii/)

- [https://www.bootschool.net/ascii](https://www.bootschool.net/ascii)

```ts
// vite.config.ts
export default defineConfig({
plugins: [
Banner(`
██ ██ ███████ ██ ██ ████████ ██ ██ ███████ ██ ██
░██ ░██ ██░░░░░██ ░██ ░██░██░░░░░ ░░██ ██ ██░░░░░██ ░██ ░██
░██ ░██ ██ ░░██░██ ░██░██ ░░████ ██ ░░██░██ ░██
░██ ░██ ░██ ░██░░██ ██ ░███████ ░░██ ░██ ░██░██ ░██
░██ ░██ ░██ ░██ ░░██ ██ ░██░░░░ ░██ ░██ ░██░██ ░██
░██ ░██ ░░██ ██ ░░████ ░██ ░██ ░░██ ██ ░██ ░██
░██ ░████████ ░░███████ ░░██ ░████████ ░██ ░░███████ ░░███████
░░ ░░░░░░░░ ░░░░░░░ ░░ ░░░░░░░░ ░░ ░░░░░░░ ░░░░░░░
`)
]
})
```

Run `npm run build`, e.g. in `app.d9a287b8.js`:

```js
/*
██ ██ ███████ ██ ██ ████████ ██ ██ ███████ ██ ██
░██ ░██ ██░░░░░██ ░██ ░██░██░░░░░ ░░██ ██ ██░░░░░██ ░██ ░██
░██ ░██ ██ ░░██░██ ░██░██ ░░████ ██ ░░██░██ ░██
░██ ░██ ░██ ░██░░██ ██ ░███████ ░░██ ░██ ░██░██ ░██
░██ ░██ ░██ ░██ ░░██ ██ ░██░░░░ ░██ ░██ ░██░██ ░██
░██ ░██ ░░██ ██ ░░████ ░██ ░██ ░░██ ██ ░██ ░██
░██ ░████████ ░░███████ ░░██ ░████████ ░██ ░░███████ ░░███████
░░ ░░░░░░░░ ░░░░░░░ ░░ ░░░░░░░░ ░░ ░░░░░░░ ░░░░░░░
*/
var e=Object.assign;import{M as t,d as a,u as r,c......
```

## License

MIT License © 2021 [chengpeiquan](https://github.com/chengpeiquan)
148 changes: 148 additions & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
<p align='center'>
<img src="https://cdn.jsdelivr.net/gh/chengpeiquan/assets-storage/img/2021/02/20210224005014.png" alt="vite-plugin-banner" />
</p>

<p align='center'>
<a href='https://www.npmjs.com/package/vite-plugin-banner'>
<img src="https://img.shields.io/npm/v/vite-plugin-banner?color=56b7ff&label=npm" />
</a>
</p>
<br>
<br>

[English](https://github.com/chengpeiquan/vite-plugin-banner/blob/main/README.md) | 简体中文

## 功能

为每个 chunk 文件头部添加 banner 注释。

## 用法

> ℹ️ **只支持 Vite 2.**
### 安装

从 npm (或者 yarn) 安装:

```bash
npm install --save-dev vite-plugin-banner
```

### 基础用法

`vite.config.ts` 添加:

```ts
// vite.config.ts
import Banner from 'vite-plugin-banner'
// Other dependencies...

export default defineConfig({
plugins: [
Banner('This is the Banner content.'),
]
})
```

当你在你的项目上运行 `npm run build` 打包的时候,在 `dist` 文件夹(或者你在 `vite.config.ts` 配置的其他 [build.outDir](https://vitejs.dev/config/#build-outdir) ),除了 `vendor` 文件外,所有的 `js``css` 文件都会添加一个 banner 注释在文件顶部。

例如,在生成的 `app.b3a7772e.js` 里:

```js
/* This is the Banner content. */
var e=Object.assign;import{M as t,d as a,u as r,c......
```

### 高级用法

当然,最理想的 banner 注释是和你的项目信息相关联。

首先,你需要更新你的 `package.json` 文件,像这样,包含类似的字段内容:

```json
// package.json
{
"name": "chengpeiquan.com",
"version": "0.1.0",
"description": "My personal website, technology stack based on Vue.js 3.0, and Vite 2.0, use Server Side Generation.",
"author": "chengpeiquan",
"homepage": "https://chengpeiquan.com/"
}
```

然后,在你的 `vite.config.ts` 导入 `package.json`,像这样更新 banner 插件的内容:

```ts
// vite.config.ts
import pkg from './package.json'
// Other dependencies...

export default defineConfig({
plugins: [
Banner(`/**\n * name: ${pkg.name}\n * version: v${pkg.version}\n * description: v${pkg.description}\n * author: ${pkg.author}\n * homepage: ${pkg.homepage}\n */`),
]
})
```

运行 `npm run build` 打包, 你可以看到生成出来的 banner 注释更详细:

例如,在生成的 `app.b3a7772e.js` 里:

```js
/**
* name: chengpeiquan.com
* version: v0.1.0
* description: vMy personal website, technology stack based on Vue.js 3.0, and Vite 2.0, use Server Side Generation.
* author: chengpeiquan
* homepage: https://chengpeiquan.com/
*/
var e=Object.assign;import{M as t,d as a,u as r,c......
```

### 趣味用法

如果你想制作一些个性化的 banner 注释,像什么表白啊、佛系啊、招聘信息啊什么的,可以通过一些在线生成器去制作有趣的内容。

比如在这些网站上可以直接生成:

- [http://www.network-science.de/ascii/](http://www.network-science.de/ascii/)

- [https://www.bootschool.net/ascii](https://www.bootschool.net/ascii)

```ts
// vite.config.ts
export default defineConfig({
plugins: [
Banner(`
██ ██ ███████ ██ ██ ████████ ██ ██ ███████ ██ ██
░██ ░██ ██░░░░░██ ░██ ░██░██░░░░░ ░░██ ██ ██░░░░░██ ░██ ░██
░██ ░██ ██ ░░██░██ ░██░██ ░░████ ██ ░░██░██ ░██
░██ ░██ ░██ ░██░░██ ██ ░███████ ░░██ ░██ ░██░██ ░██
░██ ░██ ░██ ░██ ░░██ ██ ░██░░░░ ░██ ░██ ░██░██ ░██
░██ ░██ ░░██ ██ ░░████ ░██ ░██ ░░██ ██ ░██ ░██
░██ ░████████ ░░███████ ░░██ ░████████ ░██ ░░███████ ░░███████
░░ ░░░░░░░░ ░░░░░░░ ░░ ░░░░░░░░ ░░ ░░░░░░░ ░░░░░░░
`)
]
})
```

执行 `npm run build` 打包, 还是在 `app.d9a287b8.js` ,现在变成了:

```js
/*
██ ██ ███████ ██ ██ ████████ ██ ██ ███████ ██ ██
░██ ░██ ██░░░░░██ ░██ ░██░██░░░░░ ░░██ ██ ██░░░░░██ ░██ ░██
░██ ░██ ██ ░░██░██ ░██░██ ░░████ ██ ░░██░██ ░██
░██ ░██ ░██ ░██░░██ ██ ░███████ ░░██ ░██ ░██░██ ░██
░██ ░██ ░██ ░██ ░░██ ██ ░██░░░░ ░██ ░██ ░██░██ ░██
░██ ░██ ░░██ ██ ░░████ ░██ ░██ ░░██ ██ ░██ ░██
░██ ░████████ ░░███████ ░░██ ░████████ ░██ ░░███████ ░░███████
░░ ░░░░░░░░ ░░░░░░░ ░░ ░░░░░░░░ ░░ ░░░░░░░ ░░░░░░░
*/
var e=Object.assign;import{M as t,d as a,u as r,c......
```

## License

MIT License © 2021 [chengpeiquan](https://github.com/chengpeiquan)
2 changes: 2 additions & 0 deletions dist/checkComment.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const checkComment: (comment: string) => string;
export default checkComment;
3 changes: 3 additions & 0 deletions dist/main.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { Plugin } from 'vite';
declare const banner: (comment: string) => Plugin | unknown;
export default banner;
Loading

0 comments on commit 23a8cc4

Please sign in to comment.