vite-plugin-https
v1.0.2
Published
A Vite plugin that provides local HTTPS service.
Downloads
10
Maintainers
Readme
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, () => {});