-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
vite.config.js
66 lines (64 loc) · 1.7 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
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
import Delete from 'rollup-plugin-delete'
import autoprefixer from 'autoprefixer'
import svgLoader from 'vite-svg-loader'
const bundlingConf = {
lib: {
entry: resolve(__dirname, '/src/wave-ui/index.js'),
name: 'WaveUI',
formats: ['es', 'umd', 'cjs']
},
rollupOptions: {
plugins: [
// Rollup generates all the files, then remove what we don't want.
// @todo: find a better way.
Delete({ targets: ['dist/{images,.htaccess,ghspa.js}', 'dist/*.{ico,txt,html}'], hook: 'generateBundle' })
],
// Make sure to externalize deps that shouldn't be bundled into library.
external: ['vue'],
output: {
// Provide global variables to use in the UMD build for externalized deps.
globals: { vue: 'Vue' },
entryFileNames: 'wave-ui.[format].js',
chunkFileNames: '[name].js'
}
}
}
export default defineConfig({
define: {
'process.env': {
...process.env,
VITE_APP_VERSION: process.env.npm_package_version,
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false
}
},
plugins: [
vue({
template: {
compilerOptions: {
whitespace: 'preserve'
}
}
}),
svgLoader()
], // https://vitejs.dev/config/
css: {
preprocessorOptions: {
scss: {
api: 'modern-compiler',
additionalData: '@use "@/wave-ui/scss/variables" as *;@use "@/documentation/scss/variables" as *;'
}
},
postcss: {
plugins: [autoprefixer]
}
},
resolve: {
alias: {
'@': resolve(__dirname, '/src')
}
},
build: process.env.BUNDLE ? bundlingConf : { outDir: 'docs' }
})