Skip to content

Commit

Permalink
feat(svelte.config.js): path.assets を production build 時には `CF_PAGE…
Browse files Browse the repository at this point in the history
…S_URL` にすることで画像pathを絶対URLにする
  • Loading branch information
ryoppippi committed Jun 28, 2024
1 parent fd53d51 commit ed720e2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions svelte.config.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -34,6 +36,10 @@ const config = {
alias: {
$: relativePath('src'),
},

paths: {
assets: isDevelopment ? '' : process.env.CF_PAGES_URL,
},
},
};

Expand Down

0 comments on commit ed720e2

Please sign in to comment.