-
Notifications
You must be signed in to change notification settings - Fork 3
/
svelte.config.js
118 lines (114 loc) · 2.93 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import adapter from '@sveltejs/adapter-static';
import autoprefixer from 'autoprefixer';
import componentDocsPlugin from './bin/svelte-kit/plugins/component-docs/index.cjs';
import dsv from '@rollup/plugin-dsv';
import fs from 'fs-extra';
import { mdsvex } from 'mdsvex';
import mm from 'micromatch';
import svelteKitPagesPlugin from './bin/svelte-kit/plugins/svelte-kit-pages/index.cjs';
import sveltePreprocess from 'svelte-preprocess';
import url from 'url';
const getRootRelativePath = (homepageURL) => {
if (!homepageURL) return '';
const page = new url.URL(homepageURL);
return homepageURL
.replace(`${page.protocol}//${page.host}`, '')
.replace(/\/$/, '');
};
const pkg = fs.readJSONSync(new URL('./package.json', import.meta.url));
process.env.VITE_DATELINE = new Date().toISOString();
export default {
preprocess: [
mdsvex(),
sveltePreprocess({
preserve: ['ld+json'],
scss: {
includePaths: ['src/', 'node_modules/bootstrap/scss/'],
importer: [
(url) => {
// Redirect tilde-prefixed imports to node_modules
if (/^~/.test(url))
return { file: `node_modules/${url.replace('~', '')}` };
return null;
},
],
quietDeps: true,
},
postcss: {
plugins: [autoprefixer],
},
}),
],
extensions: ['.svelte', '.svx'],
kit: {
appDir: 'app',
paths: {
assets:
process.env.NODE_ENV === 'production' ? pkg.homepage + '/cdn' : '',
base:
process.env.NODE_ENV === 'production'
? getRootRelativePath(pkg.homepage)
: '',
},
adapter: adapter({
pages: 'docs',
assets: 'docs/cdn',
fallback: null,
precompress: false,
}),
prerender: { default: true },
trailingSlash: 'always',
files: {
assets: 'src/statics',
lib: 'src/lib',
routes: 'pages',
template: 'src/template.html',
},
package: {
dir: 'dist',
emitTypes: false,
exports: (filePath) => {
return !mm.isMatch(filePath, [
'.DS_Store',
'_docs/**',
'demos/**',
'**/_*',
'**/*.svx',
'**/*.exclude.svelte',
]);
},
files: (filePath) => {
return !mm.isMatch(filePath, [
'_docs/**',
'demos/**',
'**/_*',
'**/*.svx',
'**/*.exclude.svelte',
]);
},
},
vite: {
build: { target: 'es2015' },
server: {
fs: {
allow: ['.'],
},
},
resolve: {
alias: {
$pkg: '/package.json',
$locales: '/locales',
},
},
optimizeDeps: {
exclude: [
'svelte-fa',
'@reuters-graphics/style-theme-eisbaer',
'@component-docs',
],
include: ['lodash-es', 'pym.js'],
},
plugins: [dsv(), svelteKitPagesPlugin(), componentDocsPlugin()],
},
},
};