-
Notifications
You must be signed in to change notification settings - Fork 27
/
vite.config.js
77 lines (73 loc) · 2.24 KB
/
vite.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
import { defineConfig } from 'vite';
import { readdirSync, readFileSync } from 'node:fs';
import vue from '@vitejs/plugin-vue';
import componentsAutoImport from 'unplugin-vue-components/vite'; // eslint-disable-line import/no-unresolved
import banner from 'vite-plugin-banner';
import eslint from 'vite-plugin-eslint';
import sassGlobImport from 'vite-plugin-sass-glob-import';
import pkg from './package.json';
// https://vitejs.dev/config/
export default defineConfig({
build: {
rollupOptions: {
output: {
// https://rollupjs.org/guide/en/#outputentryfilenames
entryFileNames: 'tify.js',
// https://rollupjs.org/guide/en/#outputassetfilenames
assetFileNames: 'tify.[ext]',
},
},
},
// https://vitejs.dev/config/#environment-variables
define: {
ENV: {
version: pkg.version,
license: pkg.license,
bugsUrl: pkg.bugs.url,
contributorsUrl: `${pkg.repository.url}/blob/v${pkg.version}/CONTRIBUTORS.md`,
docsUrl: `${pkg.repository.url}/blob/v${pkg.version}/doc`,
docsLanguages: [
...new Set(readdirSync('./doc').map((file) => file.split('.')[1])),
],
repositoryUrl: pkg.repository.url,
},
},
plugins: [
// Prepend copyright notice to each compiled file
banner(
'/*!'
+ `\nTIFY v${pkg.version}`
+ `\n(c) 2017-${new Date().getFullYear()}`
+ ' Göttingen State and University Library (https://www.sub.uni-goettingen.de/)'
+ `\n${pkg.license}`
+ `\n${pkg.homepage}`
+ '\n*/',
),
componentsAutoImport({
resolvers: [
(componentName) => {
// NOTE: Full path required for unit tests with Vitest
// Replacing "\" with "/" so it works on Windows; path.normalize cannot help here
const baseDir = __dirname.replaceAll('\\', '/');
const dir = `${baseDir}/src/components${componentName.startsWith('Icon') ? '/icons' : ''}`;
return {
name: componentName,
from: `${dir}/${componentName}.vue`,
};
},
],
}),
eslint({
cache: true,
// Poor man's ignore file parser, since --ignore-path is not supported
exclude: readFileSync('.gitignore')
.toString()
.split('\n')
.filter((line) => line && !line.startsWith('#'))
.map((line) => (!line.endsWith('*') ? `${line}/**` : line)),
fix: true,
}),
sassGlobImport(),
vue(),
],
});