1 Star 0 Fork 0

VectorTree/hexo-theme-aurora

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
vite.config.js 2.38 KB
一键复制 编辑 原始数据 按行查看 历史
bennyxguo 提交于 2023-09-11 02:03 +08:00 . chore: update vite build script
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import { createHtmlPlugin } from 'vite-plugin-html-transformer'
import Pages from 'vite-plugin-pages'
import path from 'path'
// https://vitejs.dev/config/
export default ({ mode }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) }
const filenamePath =
process.env.VITE_MODE === 'production'
? '../layout/index.ejs'
: 'index.html'
const templatePath =
process.env.VITE_MODE === 'production'
? 'templates/index_prod.html'
: 'templates/index.html'
return defineConfig({
build: {
outDir: 'source',
assetsDir: 'static',
rollupOptions: {
output: {
assetFileNames: assetInfo => {
let extType = assetInfo.name.split('.').at(1)
if (/png|jpe?g|svg|gif|tiff|bmp|ico/i.test(extType)) {
extType = 'img'
}
return `static/${extType}/[hash][extname]`
},
chunkFileNames: 'static/js/[hash].js',
entryFileNames: 'static/js/[hash].js'
},
plugins: []
}
},
plugins: [
createSvgIconsPlugin({
// Specify the icon folder to be cached
iconDirs: [path.resolve(process.cwd(), 'src/icons')],
// Specify symbolId format
symbolId: 'icon-[dir]-[name]',
/**
* custom insert position
* @default: body-last
*/
// inject: 'body-last' | 'body-first',
/**
* custom dom id
* @default: __svg__icons__dom__
*/
customDomId: '__svg__icons__dom__'
}),
createHtmlPlugin({
minify: true,
entry: '/src/main.ts',
filename: filenamePath,
template: templatePath
}),
vue(),
Pages({})
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src')
},
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
},
server: {
proxy: {
'/api': {
target: 'http://localhost:4000/api',
changeOrigin: true,
rewrite: path => path.replace(/^\/api/, '')
},
'/assets': {
target: 'http://localhost:4000/assets',
changeOrigin: true,
rewrite: path => path.replace(/^\/assets/, '')
}
}
}
})
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/AllocateMyAddress/hexo-theme-aurora.git
git@gitee.com:AllocateMyAddress/hexo-theme-aurora.git
AllocateMyAddress
hexo-theme-aurora
hexo-theme-aurora
main

搜索帮助