aboutsummaryrefslogtreecommitdiffstats
path: root/svelte.config.js
blob: 77a4461aa235de01fbeec7f160c01ecac52e6db6 (plain) (blame)
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
import adapter from './adapter/index.js';
import { sveltePreprocess } from 'svelte-preprocess';
import autoprefixer from 'autoprefixer';
import { transform } from 'esbuild';
import { readFileSync } from 'node:fs';

/** @type {import('@sveltejs/kit').Config} */
const config = {
  preprocess: sveltePreprocess({
    postcss: {
      plugins: [autoprefixer()],
    },
    async typescript({ content, filename }) {
      const { code, map } = await transform(content, {
        loader: 'ts',
        format: 'esm',
        charset: 'utf8',
        color: true,
        treeShaking: false,
        keepNames: true,
        sourcefile: filename,
        tsconfigRaw: {
          compilerOptions: {
            preserveValueImports: true,
          },
        },
      });
      return { code, map };
    },
    sourceMap: process.env.NODE_ENV !== 'production',
  }),
  kit: {
    adapter: adapter({
      emptyOutDir: false,
      pages: 'build',
      assets: 'build',
      paths: {
        base: '.',
        app: 'uwu',
      },
    }),
    prerender: {
      concurrency: 16,
      handleHttpError: 'ignore',
    },
    appDir: 'uwu',
    embedded: true,
    version: {
      name: process.env.REPRODUCIBLE
        ? `REPRODUCIBLE-BUILD-${readFileSync(
            '.git/' +
              readFileSync('.git/HEAD', 'utf-8').split('\n')[0].split(': ')[1],
            'utf-8'
          ).trim()}`
        : Date.now().toString(36),
    },
  },
};

export default config;