Skip to content

Commit

Permalink
feat: plugin basic ssl, initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Jul 6, 2022
0 parents commit c80acb5
Show file tree
Hide file tree
Showing 26 changed files with 3,780 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: 'ci'
on:
push:
branches:
- '**'
pull_request:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 7

- name: Set node version to 16
uses: actions/setup-node@v2
with:
node-version: 16
cache: 'pnpm'

- run: pnpm install

- name: Run tests
run: pnpm test
23 changes: 23 additions & 0 deletions .github/workflows/release-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
on:
push:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

name: Create Release

jobs:
build:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Create Release for Tag
id: release_tag
uses: yyx990803/release-tag@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
body: |
Please refer to [CHANGELOG.md](https://github.com/vitejs/vite-plugin-basic-ssl/blob/main/CHANGELOG.md) for details.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dist
node_modules
TODOs.md
temp
.DS_Store
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
semi: false
singleQuote: true
printWidth: 80
trailingComma: 'none'
arrowParens: 'avoid'
Empty file added CHANGELOG.md
Empty file.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019-present, Yuxi (Evan) You and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# @vitejs/basic-ssl [![npm](https://img.shields.io/npm/v/@vitejs/plugin-basic-ssl.svg)](https://npmjs.com/package/@vitejs/plugin-basic-ssl)

A plugin to generate untrusted certificates which still allows to access the page after proceeding a wall with warning.

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)

## Usage

```js
// vite.config.js
import basicSsl from '@vitejs/plugin-basic-ssl'

export default {
plugins: [
basicSsl()
]
}
```

## License

MIT
12 changes: 12 additions & 0 deletions build.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineBuildConfig } from 'unbuild'

export default defineBuildConfig({
entries: ['src/index'],
externals: ['vite'],
clean: true,
declaration: true,
rollup: {
emitCJS: true,
inlineDependencies: true
}
})
63 changes: 63 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"name": "@vitejs/plugin-basic-ssl",
"version": "0.1.0",
"license": "MIT",
"author": "Evan You and Vite Contributors",
"files": [
"dist"
],
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
},
"scripts": {
"dev": "unbuild --stub",
"build": "unbuild && esno scripts/patchCJS.ts",
"test": "vitest run",
"release": "node scripts/release.js",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
},
"engines": {
"node": ">=14.6.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/vitejs/vite-plugin-basic-ssl.git"
},
"bugs": {
"url": "https://github.com/vitejs/vite-plugin-basic-ssl/issues"
},
"homepage": "https://github.com/vitejs/vite-plugin-basic-ssl/#readme",
"peerDependencies": {
"vite": "^3.0.0-beta.0"
},
"devDependencies": {
"@rollup/pluginutils": "^4.2.1",
"@types/fs-extra": "^9.0.13",
"conventional-changelog-cli": "^2.2.2",
"debug": "^4.3.4",
"enquirer": "^2.3.6",
"esno": "^0.16.3",
"execa": "^4.1.0",
"fs-extra": "^10.1.0",
"hash-sum": "^2.0.0",
"minimist": "^1.2.6",
"picocolors": "^1.0.0",
"prettier": "^2.7.1",
"puppeteer": "^14.4.0",
"rollup": "^2.75.6",
"semver": "^7.3.7",
"slash": "^3.0.0",
"source-map": "^0.6.1",
"unbuild": "^0.7.4",
"vite": "^3.0.0-beta.4",
"vitest": "^0.15.1",
"node-forge": "^1.3.1"
}
}
13 changes: 13 additions & 0 deletions playground/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/main.js"></script>
</body>
</html>
20 changes: 20 additions & 0 deletions playground/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import './style.css'
import viteLogo from '/vite.svg'
import lockIcon from '/lock.svg'

document.querySelector('#app').innerHTML = `
<div>
<a href="https://vitejs.dev" target="_blank">
<img src="${viteLogo}" class="logo" alt="Vite logo" />
</a>
<a href="https://github.com/vitejs/vite-plugin-basic-ssl" target="_blank">
<img src="${lockIcon}" class="logo vanilla" alt="Lock Icon" />
</a>
<h1>Hello Vite + Basic SSL!</h1>
<p class="read-the-docs">
Example of a basic ssl setup using an automatically generated self-signed certificate
</p>
</div>
`

setupCounter(document.querySelector('#counter'))
11 changes: 11 additions & 0 deletions playground/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "vite-plugin-basic-ssl-playground",
"version": "1.0.0",
"private": true,
"description": "Example of a basic ssl setup using an automatically generated self-signed certificate",
"scripts": {
"dev": "vite",
"build": "vite build",
"serve": "vite preview"
}
}
1 change: 1 addition & 0 deletions playground/public/lock.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions playground/public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
95 changes: 95 additions & 0 deletions playground/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
:root {
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
font-size: 16px;
line-height: 24px;
font-weight: 400;

color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;

font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-text-size-adjust: 100%;
}

a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}

body {
margin: 0;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
}

h1 {
font-size: 3.2em;
line-height: 1.1;
}

#app {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}

.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}

.card {
padding: 2em;
}

.read-the-docs {
color: #888;
}

button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}

@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
}

14 changes: 14 additions & 0 deletions playground/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { defineConfig } from 'vite'
import basicSsl from '../src/index'

const config = defineConfig({
build: {
sourcemap: true,
minify: false
},
plugins: [
basicSsl()
]
})

export default config
Loading

0 comments on commit c80acb5

Please sign in to comment.