-
Notifications
You must be signed in to change notification settings - Fork 22
/
vite.config.js
47 lines (46 loc) · 1.14 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
import { fileURLToPath, URL } from 'node:url'
import { resolve } from 'path'
import { defineConfig } from 'vite'
import eslint from 'vite-plugin-eslint'
import commonjs from 'vite-plugin-commonjs'
import fs from 'fs'
import childProcess from 'child_process'
// https://vitejs.dev/config/
export default defineConfig({
base: '/',
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
plugins: [
eslint({
exclude: ['/virtual:/**', 'node_modules/**'],
}),
commonjs()
],
define: {
APP_VERSION: JSON.stringify(JSON.parse(fs.readFileSync('./package.json')).version),
GIT_HASH: JSON.stringify(childProcess.execSync('git rev-parse --short HEAD').toString().trim())
},
build: {
target: 'es2015',
lib: {
entry: resolve(__dirname, './src/index.js'),
name: 'wikipediaPreview',
fileName: 'wikipedia-preview',
},
sourcemap: true,
cssCodeSplit: true,
rollupOptions: {
output: {
assetFileNames: 'wikipedia-preview.[ext]'
}
}
},
test: {
globals: true,
environment: 'jsdom',
setupFiles: [ './test/setup.js' ],
}
})