From 742d655eb60aa3d6b80fd3c65a70677de35eb84e Mon Sep 17 00:00:00 2001 From: Theo Ephraim Date: Mon, 11 Nov 2024 14:49:05 -0800 Subject: [PATCH 1/4] update vite plugin docs --- .../content/docs/docs/integrations/vite.mdx | 81 +++++--- packages/integrations/vite/package.json | 5 +- pnpm-lock.yaml | 190 ++---------------- 3 files changed, 78 insertions(+), 198 deletions(-) diff --git a/packages/docs-site/src/content/docs/docs/integrations/vite.mdx b/packages/docs-site/src/content/docs/docs/integrations/vite.mdx index 7434eb2b..396bee18 100644 --- a/packages/docs-site/src/content/docs/docs/integrations/vite.mdx +++ b/packages/docs-site/src/content/docs/docs/integrations/vite.mdx @@ -6,7 +6,14 @@ npmPackage: "@dmno/vite-integration" import TabbedCode from '@/components/TabbedCode.astro'; -At DMNO we're big fans of [Vite](https://vitejs.dev/), which is why we offer first class integration between Vite and DMNO. +At DMNO we're big fans of [Vite](https://vitejs.dev/), and we use it under the hood to parse your `.dmno/config.mts` files. But our internal instance of Vite is decoupled from yours, so this plugins provides first class support between your use of Vite and DMNO. + +This plugin enables: +- automatic loading of dmno resolved config (no `dmno run` needed) +- build-time replacement of [static](/docs/guides/dynamic-config/) config items in your code and [html template](https://vite.dev/guide/env-and-mode#html-env-replacement) +- ability to use config items within `vite.config.ts` file +- automatic restart of the vite server on config changes +- config validation during development and build with helpful error messages ## Initialize your Vite integration @@ -51,23 +58,49 @@ The order of `injectDmnoConfigVitePlugin()` in the plugins does not matter. ## Accessing config -Now in your application code you'll have access to a global object with all of your _public_ config items (i.e., those which aren't marked `sensitive`) called `DMNO_PUBLIC_CONFIG`. +Most vanilla Vite setups are for building static front-end apps. Therefore we are mostly concerned with injecting non-sensitive static config into our built code. Use `DMNO_PUBLIC_CONFIG` instead of `process.env` or `import.meta.env`, and you'll get all the benefits of dmno, and no longer have to rely on special `PUBLIC_` prefixes. By default, **only static items referenced via `DMNO_PUBLIC_CONFIG` items will be replaced**. -```js -const publicItem = DMNO_PUBLIC_CONFIG.MY_ITEM; +```ts title='src/some-file.ts' +if (DMNO_PUBLIC_CONFIG.SERVICE_X_ENABLED) { + const client = new ServiceXClient(DMNO_PUBLIC_CONFIG.SERVICE_X_PUBLIC_KEY); +} ``` -And in any server code like your `vite.config.ts` file you can access all of your config via `DMNO_CONFIG`. +If you are building for a server/hybrid environment, you can toggle on the `injectSensitiveConfig` option to also replace static items accessed via `DMNO_CONFIG`, which will include sensitive items as well. -```js -const secretItem = DMNO_CONFIG.MY_SECRET_ITEM; -``` +```ts title="vite.config.ts" ins="injectSensitiveConfig: true" +import { defineConfig } from 'vite' +import { injectDmnoConfigVitePlugin } from '@dmno/vite-integration'; +export default defineConfig({ + plugins: [ + injectDmnoConfigVitePlugin({ injectSensitiveConfig: true }) + ], + //... +``` -:::tip[FYI] -Under the hood, for your client code, vite replaces the references to your config with actual values at build time. +:::note[Static config replacement] +Only "static" items will be replaced at build time. The default handling is controlled by a service-level `dynamicConfig` setting, and can be overrideen using the `dynamic` property on each item. See the [dynamic config guide](/docs/guides/dynamic-config/) for more info. ::: +### Using env vars within `vite.config.*` +It's often useful to be able to access configuration / env vars within your vite config. Without DMNO, it's a bit awkward, but DMNO makes it dead simple - in fact it's already available! Just reference config vars via `DMNO_CONFIG.SOME_ITEM` like you do everywhere else. + +In many vite projects, your `vite.config.*` file is not included in the same tsconfig as the rest of your code. If this is the case and you are seeing type errors about `DMNO_CONFIG` not existing, you can add a triple slash reference to the generated types. For example: + +```diff lang="ts" title="vite.config.ts" ++/// +import { defineConfig } from 'vite'; +// ... +``` +See our [TypeScript guide](/docs/guides/typescript/) for more details. + +### Using config within other scripts + +Even in a static front-end project, you may have other scripts in your project that rely on sensitive config. + +You can use [`dmno run`](/docs/reference/cli/run/) to inject resolved config into other scripts as regular environment vars. + ### HTML Env Replacement Vite [natively supports](https://vitejs.dev/guide/env-and-mode#html-env-replacement) injecting env vars into HTML files using a special syntax like `%SOME_VAR%`. @@ -79,24 +112,22 @@ Note that unlike the native functionality which does not replace missing/non-exi Note that replacements anywhere in the file, including HTML comments, are still attempted and can cause errors. For example `` will still fail! ::: +### SSR and server-side code -### SSR + dynamic config - -Currently our vite integration assumes you are doing _static_ builds, and not SSR. Therefore all config items are treated as static. - -Deeper support for ssr should be coming soon! +Unlike our [Astro](/docs/integrations/astro/) and [Remix](/docs/integrations/remix/) integrations, if you are using vanilla Vite to do SSR or build backend code, we cannot automatically infer the right way to inject dmno. In this case you may need to include an additional import that initializes the DMNO globals and security features, and run your script via `dmno run` - similar to the [Node.js integration](/docs/integrations/node/). -## Common recipes +In fact, if you don't need build-time replacements or dev server reloading, you may not need this plugin at all. -### Using env vars within `vite.config.*` -It's often useful to be able to access configuration / env vars within your vite config. Without DMNO, it's a bit awkward, but DMNO makes it dead simple - in fact it's already available! Just reference config vars via `DMNO_CONFIG.SOME_ITEM` like you do everywhere else. - -In many vite projects, your `vite.config.*` file is not included in the same tsconfig as the rest of your code. If this is the case and you are seeing type errors about `DMNO_CONFIG` not existing, you can add a triple slash reference to the generated types. For example: +```diff lang="ts" title="src/main.ts" ++import 'dmno/auto-inject-globals'; // should be imported first! -```diff lang="ts" title="vite.config.ts" -+/// -import { defineConfig } from 'vite'; -// ... +// rest of your code... ``` -See our [TypeScript guide](/docs/guides/typescript/) for more details. +```diff lang="json" title="package.json" ins="dmno run -- " +{ + // ... + "scripts": { + "start": "dmno run -- node dist/main.js", + }, +``` diff --git a/packages/integrations/vite/package.json b/packages/integrations/vite/package.json index e5370732..40cdcd1b 100644 --- a/packages/integrations/vite/package.json +++ b/packages/integrations/vite/package.json @@ -53,11 +53,12 @@ "@types/node": "catalog:", "dmno": "workspace:*", "tsup": "catalog:", - "typescript": "catalog:" + "typescript": "catalog:", + "vite": "^5.4.10" }, "peerDependencies": { "dmno": "^0", - "vite": "^5.0" + "vite": "^5" }, "dependencies": { "debug": "catalog:", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 98120403..c73d5d17 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -679,9 +679,6 @@ importers: lodash-es: specifier: 'catalog:' version: 4.17.21 - vite: - specifier: ^5.0 - version: 5.2.10(@types/node@20.14.12)(less@4.2.0) devDependencies: '@dmno/eslint-config': specifier: workspace:* @@ -710,6 +707,9 @@ importers: typescript: specifier: 'catalog:' version: 5.5.4 + vite: + specifier: ^5.4.10 + version: 5.4.11(@types/node@20.14.12)(less@4.2.0) packages/platforms/netlify: dependencies: @@ -3510,11 +3510,6 @@ packages: rollup: optional: true - '@rollup/rollup-android-arm-eabi@4.16.4': - resolution: {integrity: sha512-GkhjAaQ8oUTOKE4g4gsZ0u8K/IHU1+2WQSgS1TwTcYvL+sjbaQjNHFXbOJ6kgqGHIO1DfUhI/Sphi9GkRT9K+Q==} - cpu: [arm] - os: [android] - '@rollup/rollup-android-arm-eabi@4.19.0': resolution: {integrity: sha512-JlPfZ/C7yn5S5p0yKk7uhHTTnFlvTgLetl2VxqE518QgyM7C9bSfFTYvB/Q/ftkq0RIPY4ySxTz+/wKJ/dXC0w==} cpu: [arm] @@ -3525,11 +3520,6 @@ packages: cpu: [arm] os: [android] - '@rollup/rollup-android-arm64@4.16.4': - resolution: {integrity: sha512-Bvm6D+NPbGMQOcxvS1zUl8H7DWlywSXsphAeOnVeiZLQ+0J6Is8T7SrjGTH29KtYkiY9vld8ZnpV3G2EPbom+w==} - cpu: [arm64] - os: [android] - '@rollup/rollup-android-arm64@4.19.0': resolution: {integrity: sha512-RDxUSY8D1tWYfn00DDi5myxKgOk6RvWPxhmWexcICt/MEC6yEMr4HNCu1sXXYLw8iAsg0D44NuU+qNq7zVWCrw==} cpu: [arm64] @@ -3540,11 +3530,6 @@ packages: cpu: [arm64] os: [android] - '@rollup/rollup-darwin-arm64@4.16.4': - resolution: {integrity: sha512-i5d64MlnYBO9EkCOGe5vPR/EeDwjnKOGGdd7zKFhU5y8haKhQZTN2DgVtpODDMxUr4t2K90wTUJg7ilgND6bXw==} - cpu: [arm64] - os: [darwin] - '@rollup/rollup-darwin-arm64@4.19.0': resolution: {integrity: sha512-emvKHL4B15x6nlNTBMtIaC9tLPRpeA5jMvRLXVbl/W9Ie7HhkrE7KQjvgS9uxgatL1HmHWDXk5TTS4IaNJxbAA==} cpu: [arm64] @@ -3555,11 +3540,6 @@ packages: cpu: [arm64] os: [darwin] - '@rollup/rollup-darwin-x64@4.16.4': - resolution: {integrity: sha512-WZupV1+CdUYehaZqjaFTClJI72fjJEgTXdf4NbW69I9XyvdmztUExBtcI2yIIU6hJtYvtwS6pkTkHJz+k08mAQ==} - cpu: [x64] - os: [darwin] - '@rollup/rollup-darwin-x64@4.19.0': resolution: {integrity: sha512-fO28cWA1dC57qCd+D0rfLC4VPbh6EOJXrreBmFLWPGI9dpMlER2YwSPZzSGfq11XgcEpPukPTfEVFtw2q2nYJg==} cpu: [x64] @@ -3570,11 +3550,6 @@ packages: cpu: [x64] os: [darwin] - '@rollup/rollup-linux-arm-gnueabihf@4.16.4': - resolution: {integrity: sha512-ADm/xt86JUnmAfA9mBqFcRp//RVRt1ohGOYF6yL+IFCYqOBNwy5lbEK05xTsEoJq+/tJzg8ICUtS82WinJRuIw==} - cpu: [arm] - os: [linux] - '@rollup/rollup-linux-arm-gnueabihf@4.19.0': resolution: {integrity: sha512-2Rn36Ubxdv32NUcfm0wB1tgKqkQuft00PtM23VqLuCUR4N5jcNWDoV5iBC9jeGdgS38WK66ElncprqgMUOyomw==} cpu: [arm] @@ -3585,11 +3560,6 @@ packages: cpu: [arm] os: [linux] - '@rollup/rollup-linux-arm-musleabihf@4.16.4': - resolution: {integrity: sha512-tJfJaXPiFAG+Jn3cutp7mCs1ePltuAgRqdDZrzb1aeE3TktWWJ+g7xK9SNlaSUFw6IU4QgOxAY4rA+wZUT5Wfg==} - cpu: [arm] - os: [linux] - '@rollup/rollup-linux-arm-musleabihf@4.19.0': resolution: {integrity: sha512-gJuzIVdq/X1ZA2bHeCGCISe0VWqCoNT8BvkQ+BfsixXwTOndhtLUpOg0A1Fcx/+eA6ei6rMBzlOz4JzmiDw7JQ==} cpu: [arm] @@ -3600,11 +3570,6 @@ packages: cpu: [arm] os: [linux] - '@rollup/rollup-linux-arm64-gnu@4.16.4': - resolution: {integrity: sha512-7dy1BzQkgYlUTapDTvK997cgi0Orh5Iu7JlZVBy1MBURk7/HSbHkzRnXZa19ozy+wwD8/SlpJnOOckuNZtJR9w==} - cpu: [arm64] - os: [linux] - '@rollup/rollup-linux-arm64-gnu@4.19.0': resolution: {integrity: sha512-0EkX2HYPkSADo9cfeGFoQ7R0/wTKb7q6DdwI4Yn/ULFE1wuRRCHybxpl2goQrx4c/yzK3I8OlgtBu4xvted0ug==} cpu: [arm64] @@ -3615,11 +3580,6 @@ packages: cpu: [arm64] os: [linux] - '@rollup/rollup-linux-arm64-musl@4.16.4': - resolution: {integrity: sha512-zsFwdUw5XLD1gQe0aoU2HVceI6NEW7q7m05wA46eUAyrkeNYExObfRFQcvA6zw8lfRc5BHtan3tBpo+kqEOxmg==} - cpu: [arm64] - os: [linux] - '@rollup/rollup-linux-arm64-musl@4.19.0': resolution: {integrity: sha512-GlIQRj9px52ISomIOEUq/IojLZqzkvRpdP3cLgIE1wUWaiU5Takwlzpz002q0Nxxr1y2ZgxC2obWxjr13lvxNQ==} cpu: [arm64] @@ -3630,11 +3590,6 @@ packages: cpu: [arm64] os: [linux] - '@rollup/rollup-linux-powerpc64le-gnu@4.16.4': - resolution: {integrity: sha512-p8C3NnxXooRdNrdv6dBmRTddEapfESEUflpICDNKXpHvTjRRq1J82CbU5G3XfebIZyI3B0s074JHMWD36qOW6w==} - cpu: [ppc64] - os: [linux] - '@rollup/rollup-linux-powerpc64le-gnu@4.19.0': resolution: {integrity: sha512-N6cFJzssruDLUOKfEKeovCKiHcdwVYOT1Hs6dovDQ61+Y9n3Ek4zXvtghPPelt6U0AH4aDGnDLb83uiJMkWYzQ==} cpu: [ppc64] @@ -3645,11 +3600,6 @@ packages: cpu: [ppc64] os: [linux] - '@rollup/rollup-linux-riscv64-gnu@4.16.4': - resolution: {integrity: sha512-Lh/8ckoar4s4Id2foY7jNgitTOUQczwMWNYi+Mjt0eQ9LKhr6sK477REqQkmy8YHY3Ca3A2JJVdXnfb3Rrwkng==} - cpu: [riscv64] - os: [linux] - '@rollup/rollup-linux-riscv64-gnu@4.19.0': resolution: {integrity: sha512-2DnD3mkS2uuam/alF+I7M84koGwvn3ZVD7uG+LEWpyzo/bq8+kKnus2EVCkcvh6PlNB8QPNFOz6fWd5N8o1CYg==} cpu: [riscv64] @@ -3660,11 +3610,6 @@ packages: cpu: [riscv64] os: [linux] - '@rollup/rollup-linux-s390x-gnu@4.16.4': - resolution: {integrity: sha512-1xwwn9ZCQYuqGmulGsTZoKrrn0z2fAur2ujE60QgyDpHmBbXbxLaQiEvzJWDrscRq43c8DnuHx3QorhMTZgisQ==} - cpu: [s390x] - os: [linux] - '@rollup/rollup-linux-s390x-gnu@4.19.0': resolution: {integrity: sha512-D6pkaF7OpE7lzlTOFCB2m3Ngzu2ykw40Nka9WmKGUOTS3xcIieHe82slQlNq69sVB04ch73thKYIWz/Ian8DUA==} cpu: [s390x] @@ -3675,11 +3620,6 @@ packages: cpu: [s390x] os: [linux] - '@rollup/rollup-linux-x64-gnu@4.16.4': - resolution: {integrity: sha512-LuOGGKAJ7dfRtxVnO1i3qWc6N9sh0Em/8aZ3CezixSTM+E9Oq3OvTsvC4sm6wWjzpsIlOCnZjdluINKESflJLA==} - cpu: [x64] - os: [linux] - '@rollup/rollup-linux-x64-gnu@4.19.0': resolution: {integrity: sha512-HBndjQLP8OsdJNSxpNIN0einbDmRFg9+UQeZV1eiYupIRuZsDEoeGU43NQsS34Pp166DtwQOnpcbV/zQxM+rWA==} cpu: [x64] @@ -3690,11 +3630,6 @@ packages: cpu: [x64] os: [linux] - '@rollup/rollup-linux-x64-musl@4.16.4': - resolution: {integrity: sha512-ch86i7KkJKkLybDP2AtySFTRi5fM3KXp0PnHocHuJMdZwu7BuyIKi35BE9guMlmTpwwBTB3ljHj9IQXnTCD0vA==} - cpu: [x64] - os: [linux] - '@rollup/rollup-linux-x64-musl@4.19.0': resolution: {integrity: sha512-HxfbvfCKJe/RMYJJn0a12eiOI9OOtAUF4G6ozrFUK95BNyoJaSiBjIOHjZskTUffUrB84IPKkFG9H9nEvJGW6A==} cpu: [x64] @@ -3705,11 +3640,6 @@ packages: cpu: [x64] os: [linux] - '@rollup/rollup-win32-arm64-msvc@4.16.4': - resolution: {integrity: sha512-Ma4PwyLfOWZWayfEsNQzTDBVW8PZ6TUUN1uFTBQbF2Chv/+sjenE86lpiEwj2FiviSmSZ4Ap4MaAfl1ciF4aSA==} - cpu: [arm64] - os: [win32] - '@rollup/rollup-win32-arm64-msvc@4.19.0': resolution: {integrity: sha512-HxDMKIhmcguGTiP5TsLNolwBUK3nGGUEoV/BO9ldUBoMLBssvh4J0X8pf11i1fTV7WShWItB1bKAKjX4RQeYmg==} cpu: [arm64] @@ -3720,11 +3650,6 @@ packages: cpu: [arm64] os: [win32] - '@rollup/rollup-win32-ia32-msvc@4.16.4': - resolution: {integrity: sha512-9m/ZDrQsdo/c06uOlP3W9G2ENRVzgzbSXmXHT4hwVaDQhYcRpi9bgBT0FTG9OhESxwK0WjQxYOSfv40cU+T69w==} - cpu: [ia32] - os: [win32] - '@rollup/rollup-win32-ia32-msvc@4.19.0': resolution: {integrity: sha512-xItlIAZZaiG/u0wooGzRsx11rokP4qyc/79LkAOdznGRAbOFc+SfEdfUOszG1odsHNgwippUJavag/+W/Etc6Q==} cpu: [ia32] @@ -3735,11 +3660,6 @@ packages: cpu: [ia32] os: [win32] - '@rollup/rollup-win32-x64-msvc@4.16.4': - resolution: {integrity: sha512-YunpoOAyGLDseanENHmbFvQSfVL5BxW3k7hhy0eN4rb3gS/ct75dVD0EXOWIqFT/nE8XYW6LP6vz6ctKRi0k9A==} - cpu: [x64] - os: [win32] - '@rollup/rollup-win32-x64-msvc@4.19.0': resolution: {integrity: sha512-xNo5fV5ycvCCKqiZcpB65VMR11NJB+StnxHz20jdqRAktfdfzhgjTiJ2doTDQE/7dqGaV5I7ZGqKpgph6lCIag==} cpu: [x64] @@ -9967,11 +9887,6 @@ packages: deprecated: Rimraf versions prior to v4 are no longer supported hasBin: true - rollup@4.16.4: - resolution: {integrity: sha512-kuaTJSUbz+Wsb2ATGvEknkI12XV40vIiHmLuFlejoo7HtDok/O5eDDD0UpCVY5bBX5U5RYo8wWP83H7ZsqVEnA==} - engines: {node: '>=18.0.0', npm: '>=8.0.0'} - hasBin: true - rollup@4.19.0: resolution: {integrity: sha512-5r7EYSQIowHsK4eTZ0Y81qpZuJz+MUuYeqmmYmRMl1nwhdmbiYqt5jwzf6u7wyOzJgYqtCRMtVRKOtHANBz7rA==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} @@ -11395,8 +11310,8 @@ packages: vite: optional: true - vite@5.2.10: - resolution: {integrity: sha512-PAzgUZbP7msvQvqdSD+ErD5qGnSFiGOoWmV5yAKUEI0kdhjbH6nMWVyZQC/hSc4aXwc0oJ9aEdIiF9Oje0JFCw==} + vite@5.3.5: + resolution: {integrity: sha512-MdjglKR6AQXQb9JGiS7Rc2wC6uMjcm7Go/NHNO63EwiJXfuk9PgqiP/n5IDJCziMkfw9n4Ubp7lttNwz+8ZVKA==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true peerDependencies: @@ -11423,8 +11338,8 @@ packages: terser: optional: true - vite@5.3.5: - resolution: {integrity: sha512-MdjglKR6AQXQb9JGiS7Rc2wC6uMjcm7Go/NHNO63EwiJXfuk9PgqiP/n5IDJCziMkfw9n4Ubp7lttNwz+8ZVKA==} + vite@5.4.11: + resolution: {integrity: sha512-c7jFQRklXua0mTzneGW9QVyxFjUgwcihC4bXEtujIo2ouWCe1Ajt/amn2PCxYnhYfd5k09JX3SB7OYWFKYqj8Q==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true peerDependencies: @@ -11432,6 +11347,7 @@ packages: less: '*' lightningcss: ^1.21.0 sass: '*' + sass-embedded: '*' stylus: '*' sugarss: '*' terser: ^5.4.0 @@ -11444,6 +11360,8 @@ packages: optional: true sass: optional: true + sass-embedded: + optional: true stylus: optional: true sugarss: @@ -14982,144 +14900,96 @@ snapshots: optionalDependencies: rollup: 4.21.3 - '@rollup/rollup-android-arm-eabi@4.16.4': - optional: true - '@rollup/rollup-android-arm-eabi@4.19.0': optional: true '@rollup/rollup-android-arm-eabi@4.21.3': optional: true - '@rollup/rollup-android-arm64@4.16.4': - optional: true - '@rollup/rollup-android-arm64@4.19.0': optional: true '@rollup/rollup-android-arm64@4.21.3': optional: true - '@rollup/rollup-darwin-arm64@4.16.4': - optional: true - '@rollup/rollup-darwin-arm64@4.19.0': optional: true '@rollup/rollup-darwin-arm64@4.21.3': optional: true - '@rollup/rollup-darwin-x64@4.16.4': - optional: true - '@rollup/rollup-darwin-x64@4.19.0': optional: true '@rollup/rollup-darwin-x64@4.21.3': optional: true - '@rollup/rollup-linux-arm-gnueabihf@4.16.4': - optional: true - '@rollup/rollup-linux-arm-gnueabihf@4.19.0': optional: true '@rollup/rollup-linux-arm-gnueabihf@4.21.3': optional: true - '@rollup/rollup-linux-arm-musleabihf@4.16.4': - optional: true - '@rollup/rollup-linux-arm-musleabihf@4.19.0': optional: true '@rollup/rollup-linux-arm-musleabihf@4.21.3': optional: true - '@rollup/rollup-linux-arm64-gnu@4.16.4': - optional: true - '@rollup/rollup-linux-arm64-gnu@4.19.0': optional: true '@rollup/rollup-linux-arm64-gnu@4.21.3': optional: true - '@rollup/rollup-linux-arm64-musl@4.16.4': - optional: true - '@rollup/rollup-linux-arm64-musl@4.19.0': optional: true '@rollup/rollup-linux-arm64-musl@4.21.3': optional: true - '@rollup/rollup-linux-powerpc64le-gnu@4.16.4': - optional: true - '@rollup/rollup-linux-powerpc64le-gnu@4.19.0': optional: true '@rollup/rollup-linux-powerpc64le-gnu@4.21.3': optional: true - '@rollup/rollup-linux-riscv64-gnu@4.16.4': - optional: true - '@rollup/rollup-linux-riscv64-gnu@4.19.0': optional: true '@rollup/rollup-linux-riscv64-gnu@4.21.3': optional: true - '@rollup/rollup-linux-s390x-gnu@4.16.4': - optional: true - '@rollup/rollup-linux-s390x-gnu@4.19.0': optional: true '@rollup/rollup-linux-s390x-gnu@4.21.3': optional: true - '@rollup/rollup-linux-x64-gnu@4.16.4': - optional: true - '@rollup/rollup-linux-x64-gnu@4.19.0': optional: true '@rollup/rollup-linux-x64-gnu@4.21.3': optional: true - '@rollup/rollup-linux-x64-musl@4.16.4': - optional: true - '@rollup/rollup-linux-x64-musl@4.19.0': optional: true '@rollup/rollup-linux-x64-musl@4.21.3': optional: true - '@rollup/rollup-win32-arm64-msvc@4.16.4': - optional: true - '@rollup/rollup-win32-arm64-msvc@4.19.0': optional: true '@rollup/rollup-win32-arm64-msvc@4.21.3': optional: true - '@rollup/rollup-win32-ia32-msvc@4.16.4': - optional: true - '@rollup/rollup-win32-ia32-msvc@4.19.0': optional: true '@rollup/rollup-win32-ia32-msvc@4.21.3': optional: true - '@rollup/rollup-win32-x64-msvc@4.16.4': - optional: true - '@rollup/rollup-win32-x64-msvc@4.19.0': optional: true @@ -15621,7 +15491,7 @@ snapshots: lodash: 4.17.21 mlly: 1.6.1 outdent: 0.8.0 - vite: 5.4.6(@types/node@20.14.12)(less@4.2.0) + vite: 5.4.11(@types/node@20.14.12)(less@4.2.0) vite-node: 1.6.0(@types/node@20.14.12)(less@4.2.0) transitivePeerDependencies: - '@types/node' @@ -23449,28 +23319,6 @@ snapshots: dependencies: glob: 7.2.3 - rollup@4.16.4: - dependencies: - '@types/estree': 1.0.5 - optionalDependencies: - '@rollup/rollup-android-arm-eabi': 4.16.4 - '@rollup/rollup-android-arm64': 4.16.4 - '@rollup/rollup-darwin-arm64': 4.16.4 - '@rollup/rollup-darwin-x64': 4.16.4 - '@rollup/rollup-linux-arm-gnueabihf': 4.16.4 - '@rollup/rollup-linux-arm-musleabihf': 4.16.4 - '@rollup/rollup-linux-arm64-gnu': 4.16.4 - '@rollup/rollup-linux-arm64-musl': 4.16.4 - '@rollup/rollup-linux-powerpc64le-gnu': 4.16.4 - '@rollup/rollup-linux-riscv64-gnu': 4.16.4 - '@rollup/rollup-linux-s390x-gnu': 4.16.4 - '@rollup/rollup-linux-x64-gnu': 4.16.4 - '@rollup/rollup-linux-x64-musl': 4.16.4 - '@rollup/rollup-win32-arm64-msvc': 4.16.4 - '@rollup/rollup-win32-ia32-msvc': 4.16.4 - '@rollup/rollup-win32-x64-msvc': 4.16.4 - fsevents: 2.3.3 - rollup@4.19.0: dependencies: '@types/estree': 1.0.5 @@ -25092,7 +24940,7 @@ snapshots: debug: 4.3.7(supports-color@9.4.0) pathe: 1.1.2 picocolors: 1.1.0 - vite: 5.4.6(@types/node@20.14.12)(less@4.2.0) + vite: 5.4.11(@types/node@20.14.12)(less@4.2.0) transitivePeerDependencies: - '@types/node' - less @@ -25200,21 +25048,21 @@ snapshots: - supports-color - typescript - vite@5.2.10(@types/node@20.14.12)(less@4.2.0): + vite@5.3.5(@types/node@20.14.12)(less@4.2.0): dependencies: - esbuild: 0.20.2 - postcss: 8.4.38 - rollup: 4.16.4 + esbuild: 0.21.5 + postcss: 8.4.40 + rollup: 4.19.0 optionalDependencies: '@types/node': 20.14.12 fsevents: 2.3.3 less: 4.2.0 - vite@5.3.5(@types/node@20.14.12)(less@4.2.0): + vite@5.4.11(@types/node@20.14.12)(less@4.2.0): dependencies: esbuild: 0.21.5 - postcss: 8.4.40 - rollup: 4.19.0 + postcss: 8.4.47 + rollup: 4.21.3 optionalDependencies: '@types/node': 20.14.12 fsevents: 2.3.3 From fdc09295b5abf0405542a6e50a473a157ae6a34d Mon Sep 17 00:00:00 2001 From: Theo Ephraim Date: Mon, 11 Nov 2024 16:38:50 -0800 Subject: [PATCH 2/4] Apply suggestions from code review Co-authored-by: Phil Miller --- .../docs-site/src/content/docs/docs/integrations/vite.mdx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/docs-site/src/content/docs/docs/integrations/vite.mdx b/packages/docs-site/src/content/docs/docs/integrations/vite.mdx index 396bee18..b3ae2aff 100644 --- a/packages/docs-site/src/content/docs/docs/integrations/vite.mdx +++ b/packages/docs-site/src/content/docs/docs/integrations/vite.mdx @@ -12,7 +12,7 @@ This plugin enables: - automatic loading of dmno resolved config (no `dmno run` needed) - build-time replacement of [static](/docs/guides/dynamic-config/) config items in your code and [html template](https://vite.dev/guide/env-and-mode#html-env-replacement) - ability to use config items within `vite.config.ts` file -- automatic restart of the vite server on config changes +- automatic restart of the Vite server on config changes - config validation during development and build with helpful error messages ## Initialize your Vite integration @@ -80,13 +80,13 @@ export default defineConfig({ ``` :::note[Static config replacement] -Only "static" items will be replaced at build time. The default handling is controlled by a service-level `dynamicConfig` setting, and can be overrideen using the `dynamic` property on each item. See the [dynamic config guide](/docs/guides/dynamic-config/) for more info. +Only static items will be replaced at build time. The default handling is controlled by a service-level `dynamicConfig` setting, and can be overridden using the `dynamic` property on each item. See the [dynamic config guide](/docs/guides/dynamic-config/) for more info. ::: ### Using env vars within `vite.config.*` -It's often useful to be able to access configuration / env vars within your vite config. Without DMNO, it's a bit awkward, but DMNO makes it dead simple - in fact it's already available! Just reference config vars via `DMNO_CONFIG.SOME_ITEM` like you do everywhere else. +It's often useful to be able to access env vars in your vite config. Without DMNO, it's a bit awkward, but DMNO makes it dead simple - in fact it's already available! Just reference config vars via `DMNO_CONFIG.SOME_ITEM` like you do everywhere else. -In many vite projects, your `vite.config.*` file is not included in the same tsconfig as the rest of your code. If this is the case and you are seeing type errors about `DMNO_CONFIG` not existing, you can add a triple slash reference to the generated types. For example: +In many Vite projects, your `vite.config.*` file is not included in the same `tsconfig` as the rest of your code. If this is the case, and you are seeing type errors about `DMNO_CONFIG` not existing, you can add a triple slash reference to the generated types. For example: ```diff lang="ts" title="vite.config.ts" +/// From c7638c667175564a8dbb39bfe1f4d54be7c73413 Mon Sep 17 00:00:00 2001 From: Theo Ephraim Date: Mon, 11 Nov 2024 16:41:14 -0800 Subject: [PATCH 3/4] more vite docs nits --- .../docs-site/src/content/docs/docs/integrations/vite.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/docs-site/src/content/docs/docs/integrations/vite.mdx b/packages/docs-site/src/content/docs/docs/integrations/vite.mdx index b3ae2aff..6ab9ae59 100644 --- a/packages/docs-site/src/content/docs/docs/integrations/vite.mdx +++ b/packages/docs-site/src/content/docs/docs/integrations/vite.mdx @@ -11,7 +11,7 @@ At DMNO we're big fans of [Vite](https://vitejs.dev/), and we use it under the h This plugin enables: - automatic loading of dmno resolved config (no `dmno run` needed) - build-time replacement of [static](/docs/guides/dynamic-config/) config items in your code and [html template](https://vite.dev/guide/env-and-mode#html-env-replacement) -- ability to use config items within `vite.config.ts` file +- ability to use config items within `vite.config.*` file - automatic restart of the Vite server on config changes - config validation during development and build with helpful error messages @@ -32,7 +32,7 @@ If you prefer, you can install `dmno` itself and the `vite-integration` package -### Configure the dmno vite plugin +### Configure the dmno Vite plugin Update your `vite.config.ts` - import the plugin, and add to `defineConfig`: @@ -84,7 +84,7 @@ Only static items will be replaced at build time. The default handling is contro ::: ### Using env vars within `vite.config.*` -It's often useful to be able to access env vars in your vite config. Without DMNO, it's a bit awkward, but DMNO makes it dead simple - in fact it's already available! Just reference config vars via `DMNO_CONFIG.SOME_ITEM` like you do everywhere else. +It's often useful to be able to access env vars in your Vite config. Without DMNO, it's a bit awkward, but DMNO makes it dead simple - in fact it's already available! Just reference config vars via `DMNO_CONFIG.SOME_ITEM` like you do everywhere else. In many Vite projects, your `vite.config.*` file is not included in the same `tsconfig` as the rest of your code. If this is the case, and you are seeing type errors about `DMNO_CONFIG` not existing, you can add a triple slash reference to the generated types. For example: From 10a8deb63224fd8cf8f61f7a3db66a45497dc698 Mon Sep 17 00:00:00 2001 From: Theo Ephraim Date: Mon, 11 Nov 2024 16:42:15 -0800 Subject: [PATCH 4/4] add changeset --- .changeset/nine-wolves-travel.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/nine-wolves-travel.md diff --git a/.changeset/nine-wolves-travel.md b/.changeset/nine-wolves-travel.md new file mode 100644 index 00000000..90714daa --- /dev/null +++ b/.changeset/nine-wolves-travel.md @@ -0,0 +1,5 @@ +--- +"@dmno/vite-integration": patch +--- + +update vite peer dep version to just "^5"