-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathvite.config.js
More file actions
44 lines (41 loc) · 840 Bytes
/
vite.config.js
File metadata and controls
44 lines (41 loc) · 840 Bytes
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
import { sveltekit } from '@sveltejs/kit/vite';
import dsv from '@rollup/plugin-dsv';
import path from 'path';
/**
* Convert numerical values from a CSV file with `plugin-dsv`
* @param {string} value
* @returns {string|number}
*/
const processCsvValue = value => {
// Examples:
// '' => ''
// 'foo' => 'foo'
// '2018-07-22T22:25:55Z' => '2018-07-22T22:25:55Z'
// '1.23' => 1.23
// '42' => 42
const number = Number(value);
if (value !== '' && !isNaN(number)) {
return number;
} else {
return value;
}
};
/** @type {import('vite').UserConfig} */
const config = {
plugins: [
sveltekit(),
dsv({
processRow: row => {
Object.keys(row).forEach(key => {
row[key] = processCsvValue(row[key]);
});
}
})
],
resolve: {
alias: {
layercake: [path.resolve('src/lib')]
}
}
};
export default config;