1 Star 0 Fork 0

半岛的蒟蒻bddjr / BCSPanel-web-login

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
vite.config.ts 2.66 KB
一键复制 编辑 原始数据 按行查看 历史
半岛的蒟蒻bddjr 提交于 2024-06-17 13:52 . 移除打包后的哈希值
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
// import viteCompression from 'vite-plugin-compression'
import mockDevServerPlugin from 'vite-plugin-mock-dev-server'
import htmlMinimize from '@sergeymakinen/vite-plugin-html-minimize'
// https://vitejs.dev/config/
export default defineConfig({
server: {
// 监听所有地址(包括局域网与公网),方便内网调试
host: '0.0.0.0',
proxy: {
'^/api(-login)?/': 'http://0.0.0.0',
'^/login/$': 'http://0.0.0.0',
},
},
base: './',
plugins: [
mockDevServerPlugin(),
// viteCompression({
// algorithm: 'gzip',
// threshold: 256, // >=256字节时压缩
// verbose: true, // 打印压缩结果
// deleteOriginFile: false, // 不删除源文件
// filter: /\.(js|json|css)$/i // 文件名匹配
// }),
htmlMinimize({
minifierOptions: {
collapseWhitespace: true,
html5: true,
keepClosingSlash: false,
minifyCSS: true,
minifyJS: true,
removeAttributeQuotes: true,
removeComments: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
useShortDoctype: true,
}
}),
{
// script执行前阻止网页渲染
// https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/script
name: "scriptBlockingRender",
transformIndexHtml(html) {
return html.replaceAll(
'<script type="module"',
'<script type="module" blocking="render" async'
);
}
},
{
name: "removeI18nElement",
transformIndexHtml(html) {
return html.replaceAll(
'I18nElement',
''
);
}
},
// {
// // 添加版本号
// name: "WriteVersion",
// apply: 'build',
// closeBundle() {
// if (process.env.npm_package_version) {
// fs.writeFileSync("./dist/version.txt", process.env.npm_package_version)
// console.log("WriteVersion Done");
// }
// },
// },
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
build: {
target: 'es2022',
minify: 'terser',
reportCompressedSize: true, // 是否使用vite自带的方式打印压缩后的大小
rollupOptions: {
output: {
entryFileNames: `assets/[name].js`,
chunkFileNames: `assets/[name].js`,
assetFileNames: `assets/[name].[ext]`,
}
},
modulePreload: {
polyfill: false,
},
chunkSizeWarningLimit: Infinity,
cssCodeSplit: false,
assetsInlineLimit: 0,
}
})
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/bddjr/BCSPanel-web-login.git
git@gitee.com:bddjr/BCSPanel-web-login.git
bddjr
BCSPanel-web-login
BCSPanel-web-login
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891