2022-01-01 19:15:45 +08:00
|
|
|
|
import { defineConfig } from 'vite'
|
|
|
|
|
import vue from '@vitejs/plugin-vue'
|
|
|
|
|
import vueJsx from '@vitejs/plugin-vue-jsx'
|
|
|
|
|
import viteSvgIcons from 'vite-plugin-svg-icons'
|
|
|
|
|
import { resolve } from 'path'
|
|
|
|
|
import commonjs from '@rollup/plugin-commonjs'
|
2022-03-25 16:54:18 +08:00
|
|
|
|
import visualizer from 'rollup-plugin-visualizer'
|
2022-01-01 19:15:45 +08:00
|
|
|
|
|
|
|
|
|
// https://vitejs.dev/config/
|
|
|
|
|
export default defineConfig({
|
|
|
|
|
plugins: [
|
|
|
|
|
vue(),
|
|
|
|
|
|
|
|
|
|
//添加jsx/tsx支持
|
|
|
|
|
vueJsx({}),
|
|
|
|
|
|
|
|
|
|
//解决引入commonjs模块后打包出现的{'default' is not exported by XXX}错误!!
|
2022-01-29 19:49:51 +08:00
|
|
|
|
commonjs({requireReturnsDefault: true}), /* 配置requireReturnsDefault属性,
|
|
|
|
|
解决打包后引入VForm出现的"Axios is not a constructor"错!! */
|
2022-01-01 19:15:45 +08:00
|
|
|
|
|
2022-03-25 16:54:18 +08:00
|
|
|
|
//可视化Bundle
|
|
|
|
|
visualizer(),
|
|
|
|
|
|
2022-01-01 19:15:45 +08:00
|
|
|
|
viteSvgIcons({
|
|
|
|
|
// Specify the icon folder to be cached
|
|
|
|
|
iconDirs: [resolve(process.cwd(), 'src/icons/svg')],
|
|
|
|
|
// Specify symbolId format
|
|
|
|
|
symbolId: 'icon-[dir]-[name]',
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
"@": resolve(__dirname, 'src'), // 路径别名
|
|
|
|
|
},
|
|
|
|
|
extensions: ['.js', '.vue', '.json', '.ts'] // 使用路径别名时想要省略的后缀名,可以自己 增减
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
optimizeDeps: {
|
2022-01-02 14:33:25 +08:00
|
|
|
|
include: ['@/../lib/vuedraggable/dist/vuedraggable.umd.js', 'quill']
|
|
|
|
|
//include: ['quill']
|
2022-01-01 19:15:45 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
css: {
|
|
|
|
|
preprocessorOptions: {
|
|
|
|
|
scss: {
|
|
|
|
|
/* 自动引入全局scss文件 */
|
|
|
|
|
additionalData: '@import "./src/styles/global.scss";'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
build: {
|
2022-02-03 13:27:31 +08:00
|
|
|
|
//minify: false, //
|
2022-01-01 19:15:45 +08:00
|
|
|
|
lib: {
|
|
|
|
|
entry: resolve(__dirname, 'install-render.js'),
|
|
|
|
|
name: 'VFormRender',
|
2022-01-29 19:49:51 +08:00
|
|
|
|
fileName: (format) => `render.${format}.js`
|
2022-01-01 19:15:45 +08:00
|
|
|
|
},
|
|
|
|
|
rollupOptions: {
|
|
|
|
|
// 确保外部化处理那些你不想打包进库的依赖
|
|
|
|
|
external: ['vue', 'element-plus'],
|
|
|
|
|
output: {
|
2022-11-24 14:40:19 +08:00
|
|
|
|
exports: 'default', //要支持CDN引入必须设置此参数!!!
|
2022-01-01 19:15:45 +08:00
|
|
|
|
// 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
|
|
|
|
|
globals: {
|
|
|
|
|
vue: 'Vue',
|
2022-01-30 16:07:28 +08:00
|
|
|
|
'element-plus': 'ElementPlus',
|
2022-07-17 10:55:20 +08:00
|
|
|
|
},
|
|
|
|
|
assetFileNames: `render.style.css`
|
2022-01-01 19:15:45 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
})
|