-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
68 lines (65 loc) · 1.7 KB
/
vite.config.ts
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
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { libInjectCss } from 'vite-plugin-lib-inject-css'
import { globSync } from 'glob'
import { relative, extname, resolve, basename } from 'node:path';
import { fileURLToPath } from 'node:url';
import { createHash } from 'node:crypto'
import dts from 'vite-plugin-dts'
// @ts-expect-error missing types
import postcssMediaMinMax from 'postcss-media-minmax'
// https://vite.dev/config/
export default defineConfig({
plugins: [
vue(),
libInjectCss(),
dts({
tsconfigPath: resolve(__dirname, "tsconfig.lib.json")
})
],
css: {
devSourcemap: true,
postcss: {
plugins: [
postcssMediaMinMax
]
},
modules: {
generateScopedName: (className, filename) => {
const fileName = basename(filename, '.module.css')
const hash = createHash('sha256')
.update(className)
.digest('base64')
.substring(0, 5)
.replace(/\//g, 'X')
.replace(/\+/g, 'z')
return `${fileName}_${className}__${hash}`
}
}
},
build: {
copyPublicDir: false,
lib: {
entry: resolve(__dirname, 'lib/components/main.ts'),
formats: ['es']
},
rollupOptions: {
external: ['vue'],
input: Object.fromEntries(
globSync('lib/**/*.{ts,vue}', {
ignore: ['lib/**/*types*.ts']
}).map(file => [
relative(
'lib',
file.slice(0, file.length - extname(file).length)
),
fileURLToPath(new URL(file, import.meta.url))
])
),
output: {
assetFileNames: 'assets/[name][extname]',
entryFileNames: '[name].js'
}
}
}
})