Skip to content

Commit c80acb5

Browse files
committed
feat: plugin basic ssl, initial commit
0 parents  commit c80acb5

26 files changed

+3780
-0
lines changed

.github/workflows/ci.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: 'ci'
2+
on:
3+
push:
4+
branches:
5+
- '**'
6+
pull_request:
7+
branches:
8+
- main
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
15+
- name: Install pnpm
16+
uses: pnpm/action-setup@v2
17+
with:
18+
version: 7
19+
20+
- name: Set node version to 16
21+
uses: actions/setup-node@v2
22+
with:
23+
node-version: 16
24+
cache: 'pnpm'
25+
26+
- run: pnpm install
27+
28+
- name: Run tests
29+
run: pnpm test

.github/workflows/release-tag.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
on:
2+
push:
3+
tags:
4+
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
5+
6+
name: Create Release
7+
8+
jobs:
9+
build:
10+
name: Create Release
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@master
15+
- name: Create Release for Tag
16+
id: release_tag
17+
uses: yyx990803/release-tag@master
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
with:
21+
tag_name: ${{ github.ref }}
22+
body: |
23+
Please refer to [CHANGELOG.md](https://github.com/vitejs/vite-plugin-basic-ssl/blob/main/CHANGELOG.md) for details.

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
dist
2+
node_modules
3+
TODOs.md
4+
temp
5+
.DS_Store

.prettierrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
semi: false
2+
singleQuote: true
3+
printWidth: 80
4+
trailingComma: 'none'
5+
arrowParens: 'avoid'

CHANGELOG.md

Whitespace-only changes.

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019-present, Yuxi (Evan) You and contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# @vitejs/basic-ssl [![npm](https://img.shields.io/npm/v/@vitejs/plugin-basic-ssl.svg)](https://npmjs.com/package/@vitejs/plugin-basic-ssl)
2+
3+
A plugin to generate untrusted certificates which still allows to access the page after proceeding a wall with warning.
4+
5+
In most scenarios, it is recommended to generate a secure trusted certificate instead and use it to configure [`server.https`](https://vitejs.dev/config/#server-https)
6+
7+
## Usage
8+
9+
```js
10+
// vite.config.js
11+
import basicSsl from '@vitejs/plugin-basic-ssl'
12+
13+
export default {
14+
plugins: [
15+
basicSsl()
16+
]
17+
}
18+
```
19+
20+
## License
21+
22+
MIT

build.config.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { defineBuildConfig } from 'unbuild'
2+
3+
export default defineBuildConfig({
4+
entries: ['src/index'],
5+
externals: ['vite'],
6+
clean: true,
7+
declaration: true,
8+
rollup: {
9+
emitCJS: true,
10+
inlineDependencies: true
11+
}
12+
})

package.json

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"name": "@vitejs/plugin-basic-ssl",
3+
"version": "0.1.0",
4+
"license": "MIT",
5+
"author": "Evan You and Vite Contributors",
6+
"files": [
7+
"dist"
8+
],
9+
"main": "./dist/index.cjs",
10+
"module": "./dist/index.mjs",
11+
"types": "./dist/index.d.ts",
12+
"exports": {
13+
".": {
14+
"types": "./dist/index.d.ts",
15+
"import": "./dist/index.mjs",
16+
"require": "./dist/index.cjs"
17+
}
18+
},
19+
"scripts": {
20+
"dev": "unbuild --stub",
21+
"build": "unbuild && esno scripts/patchCJS.ts",
22+
"test": "vitest run",
23+
"release": "node scripts/release.js",
24+
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
25+
},
26+
"engines": {
27+
"node": ">=14.6.0"
28+
},
29+
"repository": {
30+
"type": "git",
31+
"url": "git+https://github.com/vitejs/vite-plugin-basic-ssl.git"
32+
},
33+
"bugs": {
34+
"url": "https://github.com/vitejs/vite-plugin-basic-ssl/issues"
35+
},
36+
"homepage": "https://github.com/vitejs/vite-plugin-basic-ssl/#readme",
37+
"peerDependencies": {
38+
"vite": "^3.0.0-beta.0"
39+
},
40+
"devDependencies": {
41+
"@rollup/pluginutils": "^4.2.1",
42+
"@types/fs-extra": "^9.0.13",
43+
"conventional-changelog-cli": "^2.2.2",
44+
"debug": "^4.3.4",
45+
"enquirer": "^2.3.6",
46+
"esno": "^0.16.3",
47+
"execa": "^4.1.0",
48+
"fs-extra": "^10.1.0",
49+
"hash-sum": "^2.0.0",
50+
"minimist": "^1.2.6",
51+
"picocolors": "^1.0.0",
52+
"prettier": "^2.7.1",
53+
"puppeteer": "^14.4.0",
54+
"rollup": "^2.75.6",
55+
"semver": "^7.3.7",
56+
"slash": "^3.0.0",
57+
"source-map": "^0.6.1",
58+
"unbuild": "^0.7.4",
59+
"vite": "^3.0.0-beta.4",
60+
"vitest": "^0.15.1",
61+
"node-forge": "^1.3.1"
62+
}
63+
}

playground/index.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite App</title>
8+
</head>
9+
<body>
10+
<div id="app"></div>
11+
<script type="module" src="/main.js"></script>
12+
</body>
13+
</html>

playground/main.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import './style.css'
2+
import viteLogo from '/vite.svg'
3+
import lockIcon from '/lock.svg'
4+
5+
document.querySelector('#app').innerHTML = `
6+
<div>
7+
<a href="https://vitejs.dev" target="_blank">
8+
<img src="${viteLogo}" class="logo" alt="Vite logo" />
9+
</a>
10+
<a href="https://github.com/vitejs/vite-plugin-basic-ssl" target="_blank">
11+
<img src="${lockIcon}" class="logo vanilla" alt="Lock Icon" />
12+
</a>
13+
<h1>Hello Vite + Basic SSL!</h1>
14+
<p class="read-the-docs">
15+
Example of a basic ssl setup using an automatically generated self-signed certificate
16+
</p>
17+
</div>
18+
`
19+
20+
setupCounter(document.querySelector('#counter'))

playground/package.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "vite-plugin-basic-ssl-playground",
3+
"version": "1.0.0",
4+
"private": true,
5+
"description": "Example of a basic ssl setup using an automatically generated self-signed certificate",
6+
"scripts": {
7+
"dev": "vite",
8+
"build": "vite build",
9+
"serve": "vite preview"
10+
}
11+
}

playground/public/lock.svg

+1
Loading

playground/public/vite.svg

+1
Loading

playground/style.css

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
:root {
2+
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
3+
font-size: 16px;
4+
line-height: 24px;
5+
font-weight: 400;
6+
7+
color-scheme: light dark;
8+
color: rgba(255, 255, 255, 0.87);
9+
background-color: #242424;
10+
11+
font-synthesis: none;
12+
text-rendering: optimizeLegibility;
13+
-webkit-font-smoothing: antialiased;
14+
-moz-osx-font-smoothing: grayscale;
15+
-webkit-text-size-adjust: 100%;
16+
}
17+
18+
a {
19+
font-weight: 500;
20+
color: #646cff;
21+
text-decoration: inherit;
22+
}
23+
a:hover {
24+
color: #535bf2;
25+
}
26+
27+
body {
28+
margin: 0;
29+
display: flex;
30+
place-items: center;
31+
min-width: 320px;
32+
min-height: 100vh;
33+
}
34+
35+
h1 {
36+
font-size: 3.2em;
37+
line-height: 1.1;
38+
}
39+
40+
#app {
41+
max-width: 1280px;
42+
margin: 0 auto;
43+
padding: 2rem;
44+
text-align: center;
45+
}
46+
47+
.logo {
48+
height: 6em;
49+
padding: 1.5em;
50+
will-change: filter;
51+
}
52+
.logo:hover {
53+
filter: drop-shadow(0 0 2em #646cffaa);
54+
}
55+
56+
.card {
57+
padding: 2em;
58+
}
59+
60+
.read-the-docs {
61+
color: #888;
62+
}
63+
64+
button {
65+
border-radius: 8px;
66+
border: 1px solid transparent;
67+
padding: 0.6em 1.2em;
68+
font-size: 1em;
69+
font-weight: 500;
70+
font-family: inherit;
71+
background-color: #1a1a1a;
72+
cursor: pointer;
73+
transition: border-color 0.25s;
74+
}
75+
button:hover {
76+
border-color: #646cff;
77+
}
78+
button:focus,
79+
button:focus-visible {
80+
outline: 4px auto -webkit-focus-ring-color;
81+
}
82+
83+
@media (prefers-color-scheme: light) {
84+
:root {
85+
color: #213547;
86+
background-color: #ffffff;
87+
}
88+
a:hover {
89+
color: #747bff;
90+
}
91+
button {
92+
background-color: #f9f9f9;
93+
}
94+
}
95+

playground/vite.config.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { defineConfig } from 'vite'
2+
import basicSsl from '../src/index'
3+
4+
const config = defineConfig({
5+
build: {
6+
sourcemap: true,
7+
minify: false
8+
},
9+
plugins: [
10+
basicSsl()
11+
]
12+
})
13+
14+
export default config

0 commit comments

Comments
 (0)