generated from ntsd/overwolf-svelte-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 1
/
svelte.config.js
57 lines (49 loc) · 1.27 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
import adapter from '@sveltejs/adapter-static';
import { vitePreprocess } from '@sveltejs/kit/vite';
import { mdsvex } from 'mdsvex';
import { globSync } from 'glob';
import path from 'node:path';
import { readFileSync, writeFileSync } from 'node:fs';
function overwolfFix(insideAdapter, options) {
const name = 'overwolf-fix';
return {
name: insideAdapter ? `${name}, ${insideAdapter.name}` : name,
async adapt(builder) {
if (insideAdapter) {
await insideAdapter.adapt(builder);
}
const mergedOptions = {
pages: 'build',
...options
};
globSync(`${path.join(mergedOptions.pages, builder.config.kit.appDir)}/**/*.js`, {}).forEach(
(filePath) => {
let js = readFileSync(filePath).toString();
// Replace because params will be undefine and intent is not return
js = js.replace('if (params) {', 'if (params|true) {');
writeFileSync(filePath, js);
}
);
}
};
}
const config = {
extensions: ['.svelte', '.svx', '.md'],
preprocess: [vitePreprocess(), mdsvex({ extensions: ['.svx', '.md'] })],
kit: {
paths: {
base: '',
relative: true
},
adapter: overwolfFix(
adapter({
pages: 'build',
assets: 'build',
fallback: 'index.html',
precompress: false,
strict: true
})
)
}
};
export default config;