diff --git a/package.json b/package.json index e884cf5c..4a6b30a4 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "eslint": "^9.5.0", "eslint-plugin-format": "^0.1.2", "eslint-plugin-svelte": "^2.41.0", + "std-env": "^3.7.0", "svelte": "5.0.0-next.166", "svelte-check": "^3.8.4", "svelte-eslint-parser": "^0.36.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a82f1e9e..ec6f1c5f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -39,6 +39,9 @@ importers: eslint-plugin-svelte: specifier: ^2.41.0 version: 2.41.0(eslint@9.5.0)(svelte@5.0.0-next.166) + std-env: + specifier: ^3.7.0 + version: 3.7.0 svelte: specifier: 5.0.0-next.166 version: 5.0.0-next.166 @@ -2233,6 +2236,9 @@ packages: spdx-license-ids@3.0.18: resolution: {integrity: sha512-xxRs31BqRYHwiMzudOrpSiHtZ8i/GeionCBDSilhYRj+9gIcI8wCZTlXZKu9vZIVqViP3dcp9qE5G6AlIaD+TQ==} + std-env@3.7.0: + resolution: {integrity: sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==} + string-argv@0.3.2: resolution: {integrity: sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q==} engines: {node: '>=0.6.19'} @@ -4911,6 +4917,8 @@ snapshots: spdx-license-ids@3.0.18: {} + std-env@3.7.0: {} + string-argv@0.3.2: {} string-width@4.2.3: diff --git a/svelte.config.js b/svelte.config.js index 5fbbee1f..a0ebb99d 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -1,6 +1,8 @@ +import process from 'node:process'; import path from 'node:path'; import adapter from '@sveltejs/adapter-static'; import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; +import { isDevelopment } from 'std-env'; /** @param {...string} args */ function relativePath(...args) { @@ -34,6 +36,10 @@ const config = { alias: { $: relativePath('src'), }, + + paths: { + assets: isDevelopment ? '' : process.env.CF_PAGES_URL, + }, }, };