diff --git a/docs/guide/configuration.md b/docs/guide/configuration.md index 372e193..5351293 100644 --- a/docs/guide/configuration.md +++ b/docs/guide/configuration.md @@ -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. diff --git a/npm/package.json b/npm/package.json index 0254ff8..3219b28 100644 --- a/npm/package.json +++ b/npm/package.json @@ -1,6 +1,6 @@ { "name": "laravel-vite", - "version": "0.0.17", + "version": "0.0.18", "author": "Enzo Innocenzi", "license": "MIT", "main": "dist/index.js", @@ -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" } } diff --git a/npm/src/index.ts b/npm/src/index.ts index 245a16a..81ab1c8 100644 --- a/npm/src/index.ts +++ b/npm/src/index.ts @@ -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) } diff --git a/npm/yarn.lock b/npm/yarn.lock index 24c5437..0c80a4c 100644 --- a/npm/yarn.lock +++ b/npm/yarn.lock @@ -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==