Skip to content

Commit

Permalink
fix: https on dev server
Browse files Browse the repository at this point in the history
  • Loading branch information
rocwang committed Jan 13, 2021
1 parent 2f32b2f commit 4d7f312
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { homedir } from "os";
import { readFileSync } from "fs";
import { existsSync, readFileSync } from "fs";

export default defineConfig({
plugins: [vue()],
server: {
open: true,
https:
process.env.NODE_ENV === "development"
? {
key: readFileSync(homedir() + "/.localhost_ssl/server.key"),
cert: readFileSync(homedir() + "/.localhost_ssl/server.crt"),
}
: false,
https: existsSync(`${homedir()}/.localhost_ssl/server.key`)
? {
key: readFileSync(`${homedir()}/.localhost_ssl/server.key`),
cert: readFileSync(`${homedir()}/.localhost_ssl/server.crt`),
}
: false,
},
optimizeDeps: {
exclude: ["prettier"],
Expand Down

0 comments on commit 4d7f312

Please sign in to comment.