代码拉取完成,页面将自动刷新
同步操作将从 gist006/vue3-basic-template 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import type { UserConfig, ConfigEnv } from "vite";
import path from "path";
import vue from "@vitejs/plugin-vue";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
import { viteMockServe } from "vite-plugin-mock";
import vueJsx from "@vitejs/plugin-vue-jsx";
import vueSetupExtend from "vite-plugin-vue-setup-extend";
const resolve = (dir: string) => path.join(__dirname, dir);
export default ({ command, mode }: ConfigEnv): UserConfig => {
const root = process.cwd();
const isBuild = command === "build";
return {
base: "./",
root,
plugins: [
vue(),
vueJsx(),
vueSetupExtend(),
AutoImport({
// 设置为false,即为不自动导入,设置为路径即在当前路径生成自动导入文件 true即默认./auto-import.d.ts
dts: resolve("./src/components.d.ts"),
imports: [
"vue",
"pinia",
"vue-router",
{
"@vueuse/core": []
}
],
eslintrc: {
enabled: true, // Default `false`
filepath: resolve("./.eslintrc-auto-import.json"), // Default `./.eslintrc-auto-import.json`
globalsPropValue: true // Default `true`, (true | false | 'readonly' | 'readable' | 'writable' | 'writeable')
},
resolvers: [ElementPlusResolver()]
}),
Components({
extensions: ["vue", "md"],
dts: resolve("./src/auto-imports.d.ts"),
include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
exclude: [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/, /[\\/]\.nuxt[\\/]/],
resolvers: [ElementPlusResolver()]
}),
createSvgIconsPlugin({
iconDirs: [resolve("./src/icons")],
// 指定symbolId格式
symbolId: "svg-[name]"
}),
viteMockServe({
// mock文件目录
mockPath: "mock",
// 本地调试
localEnabled: !isBuild,
// 打包mock
prodEnabled: isBuild,
// 生产使用mock
injectCode: `
import { setupProdMockServer } from './mockProdServer';
setupProdMockServer();
`
})
],
optimizeDeps: {
// 预加载
include: ["element-plus/es/locale/lang/zh-cn"]
},
resolve: {
alias: {
"~/": `${path.resolve(__dirname, "src")}/`,
"@": resolve("src")
}
},
css: {
preprocessorOptions: {
scss: {
additionalData: `@use "~/styles/theme/index.scss" as *;`
}
}
},
server: {
host: "0.0.0.0",
port: 4000, // 服务端口号
open: true // 服务启动时是否自动打开浏览器
},
build: {
reportCompressedSize: false,
chunkSizeWarningLimit: 2000,
rollupOptions: {
// 静态资源分类打包
output: {
chunkFileNames: "static/js/[name]-[hash].js",
entryFileNames: "static/js/[name]-[hash].js",
assetFileNames: "static/[ext]/[name]-[hash].[ext]"
}
}
},
define: {
// 解决打包报错
__INTLIFY_PROD_DEVTOOLS__: JSON.stringify(false)
}
};
};
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。