2021-12-25 11:36:55 +00: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'
|
2022-01-01 11:15:45 +00:00
|
|
|
|
import commonjs from '@rollup/plugin-commonjs'
|
2022-01-30 08:07:28 +00:00
|
|
|
|
import externalGlobals from "rollup-plugin-external-globals"
|
2021-12-25 11:36:55 +00:00
|
|
|
|
|
|
|
|
|
// https://vitejs.dev/config/
|
|
|
|
|
export default defineConfig({
|
2022-01-30 08:07:28 +00:00
|
|
|
|
base: '',
|
2021-12-25 11:36:55 +00:00
|
|
|
|
plugins: [
|
|
|
|
|
vue(),
|
|
|
|
|
|
|
|
|
|
//添加jsx/tsx支持
|
|
|
|
|
vueJsx({}),
|
|
|
|
|
|
2022-01-30 08:07:28 +00:00
|
|
|
|
/* 开启externalGlobals后,
|
|
|
|
|
报错:TypeError: Cannot read properties of null (reading 'nodeType'),不知何故?? */
|
|
|
|
|
// externalGlobals({
|
|
|
|
|
// vue: "Vue",
|
|
|
|
|
// 'element-plus': 'ElementPlus',
|
|
|
|
|
// }),
|
2022-01-01 11:15:45 +00:00
|
|
|
|
|
2021-12-25 11:36:55 +00: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'] // 使用路径别名时想要省略的后缀名,可以自己 增减
|
|
|
|
|
},
|
|
|
|
|
|
2022-01-01 11:15:45 +00:00
|
|
|
|
optimizeDeps: {
|
2022-01-02 06:33:25 +00:00
|
|
|
|
include: ['@/../lib/vuedraggable/dist/vuedraggable.umd.js', 'quill']
|
2022-01-01 11:15:45 +00:00
|
|
|
|
},
|
|
|
|
|
|
2021-12-25 11:36:55 +00:00
|
|
|
|
css: {
|
|
|
|
|
preprocessorOptions: {
|
|
|
|
|
scss: {
|
|
|
|
|
/* 自动引入全局scss文件 */
|
|
|
|
|
additionalData: '@import "./src/styles/global.scss";'
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-01-01 11:15:45 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
build: {
|
2022-03-08 09:59:10 +00:00
|
|
|
|
//minify: false,
|
2022-01-30 08:07:28 +00:00
|
|
|
|
commonjsOptions: {
|
|
|
|
|
exclude: [
|
2022-02-02 07:19:09 +00:00
|
|
|
|
'lib/vuedraggable/dist/vuedraggable.umd.js,', //引号前的逗号不能删,不知何故??
|
|
|
|
|
//'vue/dist/*.js'
|
|
|
|
|
],
|
2022-01-30 08:07:28 +00:00
|
|
|
|
include: []
|
|
|
|
|
//requireReturnsDefault: true
|
|
|
|
|
},
|
2022-01-01 11:15:45 +00:00
|
|
|
|
rollupOptions: {
|
2022-01-30 08:07:28 +00:00
|
|
|
|
// 指定生产打包入口文件为index.htm
|
|
|
|
|
input: {
|
|
|
|
|
main: resolve(__dirname, 'index.html'),
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// // 确保外部化处理那些你不想打包进库的依赖
|
|
|
|
|
// external: ['vue', 'element-plus'],
|
|
|
|
|
// output: {
|
|
|
|
|
// // 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
|
|
|
|
|
// globals: {
|
|
|
|
|
// vue: 'Vue', //报错:Failed to resolve module specifier "vue". Relative references must start with either
|
|
|
|
|
// 'element-plus': 'ElementPlus',
|
|
|
|
|
// }
|
|
|
|
|
// }
|
2022-01-01 11:15:45 +00:00
|
|
|
|
}
|
2021-12-25 11:36:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
})
|