1 Star 11 Fork 8

三脚含树/vue3-template

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
vite.config.js 1.76 KB
一键复制 编辑 原始数据 按行查看 历史
三脚含树 提交于 2022-12-12 16:50 +08:00 . 1 添加全局导入静态资源提示
import { defineConfig } from 'vite';
import { resolve } from 'path';
import { envResolver } from './config/index.js';
import { getPlugins } from './config/plugins';
// 分开打包
const splitDependencies = [];
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => Object.assign(
envResolver[mode](),
{
base: '/',
server: {
// 是否开启 https
https: false,
// 端口号
port: 80,
// 监听所有地址 127.0.0.1 localhost 192.168.1.x
host: '0.0.0.0',
// 服务启动时是否自动打开浏览器
open: true,
// 允许跨域
cors: true,
// 自定义代理规则
proxy: {},
},
build: {
// 设置最终构建的浏览器兼容目标
target: 'es2015',
// 构建后是否生成 source map 文件
sourcemap: false,
// chunk 大小警告的限制(以 kb为单位)
chunkSizeWarningLimit: 2048,
// 启用/禁用 gzip 压缩大小报告
reportCompressedSize: false,
rollupOptions: {
// 输出文件命名
output: {
chunkFileNames: 'static/js/[name]-[hash].js',
entryFileNames: 'static/js/[name]-[hash].js',
assetFileNames: 'static/[ext]/[name]-[hash].[ext]',
manualChunks(id) {
// 创建一个vendor包含所有依赖项的块node_modules
for (const dependency of splitDependencies) {
if (id.includes(dependency)) {
console.log('output=> id', id);
return dependency;
}
}
}
}
}
},
envDir: resolve(__dirname, 'config/env'),
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
},
},
plugins: getPlugins(mode)
},
));
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/aj_aj/vue3-template.git
git@gitee.com:aj_aj/vue3-template.git
aj_aj
vue3-template
vue3-template
master

搜索帮助