-
Notifications
You must be signed in to change notification settings - Fork 1
/
svelte.config.js
63 lines (55 loc) · 2.25 KB
/
svelte.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import path from 'node:path';
import process from 'node:process';
import adapter from '@sveltejs/adapter-static';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
import { isDevelopment } from 'std-env';
import { budouxPreprocess } from 'svelte-preprocess-budoux';
/** @param {...string} args */
function relativePath(...args) {
return path.resolve(import.meta.dirname, ...args);
}
/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
// for more information about preprocessors
preprocess: [
vitePreprocess(),
budouxPreprocess({ language: 'ja', attribute: 'data-budoux' }), // budouxを使って日本語の改行をいい感じにする。 https://github.com/google/budoux/tree/main/javascript https://github.com/ryoppippi/svelte-preprocess-budoux
],
vitePlugin: {
dynamicCompileOptions({ filename }) {
/* sveltekit-tweet が rune に対応していないので、user script のみ rune を強制する https://github.com/sveltejs/svelte/issues/9632#issuecomment-1825498213 */
if (!filename.includes('node_modules')) {
return { runes: true };
}
},
},
kit: {
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
adapter: adapter({
fallback: '404.html',
}),
typescript: {
config(config) {
config.include.push(path.join(import.meta.dirname, 'uno.config.ts'));
},
},
alias: {
$: relativePath('src'),
},
paths: {
/**
@see https://developers.cloudflare.com/pages/configuration/build-configuration#environment-variables
@see https://kit.svelte.jp/docs/configuration#paths
*/
assets: isDevelopment
? '' // もし開発環境ならば、相対パスでアクセスする
: process.env.CF_PAGES_BRANCH === 'main'
? `https:///vim-jp-radio.com` // もし本番環境で、main ブランチならば、vim-jp-radio.com からアクセスする
: process.env.CF_PAGES_URL, // それ以外の場合は、CF_PAGES_URL からアクセスする
},
},
};
export default config;