Skip to content

Commit

Permalink
feat: infer environment certificates
Browse files Browse the repository at this point in the history
  • Loading branch information
innocenzi committed Sep 27, 2021
1 parent ea5bab2 commit 70983ab
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
7 changes: 7 additions & 0 deletions docs/guide/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@ export default defineConfig()
]))
```

Alternatively, using `withCertificates` without argumentse will use the `VITE_DEV_KEY` and `VITE_DEV_CERT` environment variables by default:

```ts
export default defineConfig()
.withCertificates()
```

#### Laravel Valet

If you use Laravel Valet, you can use `withValetCertificates`. The domain name will be determined from your `APP_URL` environment variable, but you can override it by passing it as the `domain` property of the first parameter of the method.
Expand Down
5 changes: 2 additions & 3 deletions npm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "laravel-vite",
"version": "0.0.17",
"version": "0.0.18",
"author": "Enzo Innocenzi",
"license": "MIT",
"main": "dist/index.js",
Expand Down Expand Up @@ -37,7 +37,6 @@
"debug": "^4.3.2",
"deepmerge": "^4.2.2",
"dotenv": "^10.0.0",
"execa": "^5.1.1",
"postcss": "^8.3.8"
"execa": "^5.1.1"
}
}
8 changes: 7 additions & 1 deletion npm/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,15 @@ export class ViteConfiguration {
/**
* Configures the development server to use the certificates at the given paths.
*/
public withCertificates(): this
public withCertificates(callback: (env: typeof process.env) => [string, string]): this
public withCertificates(key: string, cert: string): this
public withCertificates(callbackOrKey: string | ((env: typeof process.env) => [string, string]), cert?: string): this {
public withCertificates(callbackOrKey?: string | ((env: typeof process.env) => [string, string]), cert?: string): this {
if (!callbackOrKey && !cert) {
callbackOrKey = process.env.VITE_DEV_KEY
cert = process.env.VITE_DEV_CERT
}

if (typeof callbackOrKey === 'function') {
[callbackOrKey, cert] = callbackOrKey(process.env)
}
Expand Down
2 changes: 1 addition & 1 deletion npm/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1940,7 +1940,7 @@ postcss-load-config@^3.0.1:
cosmiconfig "^7.0.0"
import-cwd "^3.0.0"

postcss@^8.3.6, postcss@^8.3.8:
postcss@^8.3.6:
version "8.3.8"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.3.8.tgz#9ebe2a127396b4b4570ae9f7770e7fb83db2bac1"
integrity sha512-GT5bTjjZnwDifajzczOC+r3FI3Cu+PgPvrsjhQdRqa2kTJ4968/X9CUce9xttIB0xOs5c6xf0TCWZo/y9lF6bA==
Expand Down

0 comments on commit 70983ab

Please # to comment.