forked from angryziber/kotlin-jooby-svelte-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnowpack.config.mjs
71 lines (65 loc) · 1.75 KB
/
snowpack.config.mjs
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
import proxy from 'http2-proxy'
const svelteIgnore = [
'a11y-autofocus',
'a11y-no-onchange',
'a11y-missing-attribute',
'a11y-label-has-associated-control'
]
const isTest = process.env.NODE_ENV === 'test'
const plugins = [
'@snowpack/plugin-typescript',
'@snowpack/plugin-svelte',
['@snowpack/plugin-run-script',
{cmd: 'svelte-check --output human --compiler-warnings ' + svelteIgnore.map(i => i + ':ignore').join(','), watch: '$1 --watch', output: 'stream'}
]
]
if (!isTest) {
const sassCmd = 'sass -I node_modules ui/assets/scss:build/public/css'
plugins.push(['@snowpack/plugin-run-script', {
cmd: `${sassCmd} --no-source-map --style=compressed`, watch: `${sassCmd} --embed-source-map --watch`
}])
}
const proxyOptions = {
hostname: 'localhost', port: 8080,
onReq: (req, {headers}) => {headers['x-forwarded-host'] = req.headers['host']}
}
/** @type {import("snowpack").SnowpackUserConfig } */
export default {
mount: {
public: '/',
'build/public/css': {url: '/css', static: true, resolve: false},
ui: '/_dist_/ui',
i18n: '/_dist_/i18n'
},
alias: {
'@ui': './ui'
},
exclude: [
'**/node_modules/**/*',
'**/*.test.ts',
'**/ui/test-utils.ts',
'**/ui/setup-tests.ts',
'**/_*.scss'
],
plugins,
packageOptions: {
knownEntrypoints: isTest ? ['sinon', 'chai', 'sinon-chai', '@testing-library/svelte'] : []
},
buildOptions: {
out: 'build/public',
sourcemap: true
},
optimize: {
sourcemap: false,
minify: true,
target: 'es2020'
},
routes: [
{src: '/api/.*', dest: (req, res) => proxy.web(req, res, proxyOptions).catch(() => res.end())},
{match: 'routes', src: '.*', dest: '/index.html'}
],
devOptions: {
port: isTest ? 8678 : 8088,
open: 'none'
}
}