-
Notifications
You must be signed in to change notification settings - Fork 2
/
vite.config.ts
46 lines (43 loc) · 1.2 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
import type { Plugin } from 'vite'
import { defineConfig } from 'vite'
import dts from 'vite-plugin-dts'
import path from 'node:path'
let removeCommentsPlugin = (): Plugin => ({
generateBundle: (_options, bundle): void => {
let chunks = Object.values(bundle).filter(chunk => chunk.type === 'chunk')
for (let chunk of chunks) {
chunk.code = chunk.code
.replaceAll(/^[\t ]*\/\*[\s\S]*?\*\/\s*$|^[\t ]*\/\/.*$/gmu, '')
.replaceAll(/^[\t ]*[\n\r]/gmu, '')
}
},
name: 'remove-comments',
})
export default defineConfig({
build: {
lib: {
fileName: (format, entryName) =>
`${entryName}${format === 'cjs' ? '.cjs' : '.mjs'}`,
entry: path.resolve(import.meta.dirname, 'index.ts'),
name: '@azat-io/eslint-config',
formats: ['cjs', 'es'],
},
rollupOptions: {
output: {
preserveModules: true,
exports: 'auto',
},
external: (id: string) => !id.startsWith('.') && !path.isAbsolute(id),
},
minify: false,
},
plugins: [
dts({
include: [
path.join(import.meta.dirname, 'environment.d.ts'),
path.join(import.meta.dirname, 'index.ts'),
],
}),
removeCommentsPlugin(),
],
})