1.0.2 • Published 2 years ago

vite-plugin-https v1.0.2

Weekly downloads
-
License
UNLICENSED
Repository
github
Last release
2 years ago

VITE_PLUGIN_HTTPS

Utilizes devcert to provide HTTPS service.

Usage

import pluginHttps from "vite-plugins-https";

export default defineConfig({
  plugins: [httpsPlugin()],
});

Vite Middleware Mode

When you use the middleware mode in Vite, this plugin will not take effect because you need to manually pass the HTTPS options to your custom server.

import { certificateFor } from '@childrentime/devcert'

const app = express();
const viteServer = await createViteServer({
  // ...options,
  server: { middlewareMode: true },
  appType: "custom",
});
app.use(viteServer.middlewares);

// instead of
const server = app.listen(port, () => {});

// use
const localHttpsOptions = await certificateFor(["localhost"]);
const server = https.createServer(localHttpsOptions, app);
server.listen(port, () => {});