-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathvite.config.js
71 lines (68 loc) · 1.84 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
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'node:path'
import autoprefixer from 'autoprefixer'
import pkg from './package.json'
const banner = `/**
* ${pkg.name} v${pkg.version}
* (c) 2024-${new Date().getFullYear()} ${pkg.author}
* @license MIT
*/\n`
const bundlingConf = {
minify: true,
lib: {
entry: resolve(__dirname, 'src/vue-cal/index.js'),
name: 'vuecal', // The global name of the library.
fileName: format => `vue-cal.${format}.js` // Output filename pattern.
},
rollupOptions: {
// Make sure to externalize deps that shouldn't be bundled into library.
external: id => {
if (id === 'vue') return true // Externalize vue.
return false
},
output: {
banner,
globals: { vue: 'Vue' }, // Vue should be treated as external and available as a global variable.
chunkFileNames: chunkInfo => {
if (chunkInfo.facadeModuleId.endsWith('.json')) return 'i18n/[name].js' // Match JSON to JS name without a hash.
return '[name]-[hash].js' // Default behavior.
}
}
},
copyPublicDir: false // Prevent copying `public/` to `dist` folder.
}
export default defineConfig({
define: {
'process.env': {
VITE_APP_VERSION: process.env.npm_package_version,
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false
}
},
plugins: [
vue({
template: {
compilerOptions: {
whitespace: 'preserve'
}
}
})
], // https://vitejs.dev/config/
resolve: {
alias: {
'@': resolve(__dirname, 'src')
}
},
css: {
preprocessorOptions: {
scss: {
api: 'modern-compiler',
additionalData: '@use "@/scss/variables" as *;'
}
},
postcss: {
plugins: [autoprefixer]
}
},
build: process.env.BUNDLE ? bundlingConf : { outDir: 'docs' }
})