1 Star 0 Fork 641

ocean/basic

forked from Fantastic-admin/basic 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
vite.config.ts 1.85 KB
一键复制 编辑 原始数据 按行查看 历史
Hooray 提交于 2024-09-25 17:02 . refactor: 将 sass 替换为 sass-embedded
import fs from 'node:fs'
import path from 'node:path'
import process from 'node:process'
import dayjs from 'dayjs'
import { defineConfig, loadEnv } from 'vite'
import pkg from './package.json'
import createVitePlugins from './vite/plugins'
// https://vitejs.dev/config/
export default defineConfig(({ mode, command }) => {
const env = loadEnv(mode, process.cwd())
// 全局 scss 资源
const scssResources: string[] = []
fs.readdirSync('src/assets/styles/resources').forEach((dirname) => {
if (fs.statSync(`src/assets/styles/resources/${dirname}`).isFile()) {
scssResources.push(`@use "/src/assets/styles/resources/${dirname}" as *;`)
}
})
return {
// 开发服务器选项 https://cn.vitejs.dev/config/server-options
server: {
open: true,
port: 9000,
proxy: {
'/proxy': {
target: env.VITE_APP_API_BASEURL,
changeOrigin: command === 'serve' && env.VITE_OPEN_PROXY === 'true',
rewrite: path => path.replace(/\/proxy/, ''),
},
},
},
// 构建选项 https://cn.vitejs.dev/config/build-options
build: {
outDir: mode === 'production' ? 'dist' : `dist-${mode}`,
sourcemap: env.VITE_BUILD_SOURCEMAP === 'true',
},
define: {
__SYSTEM_INFO__: JSON.stringify({
pkg: {
version: pkg.version,
dependencies: pkg.dependencies,
devDependencies: pkg.devDependencies,
},
lastBuildTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
}),
},
plugins: createVitePlugins(mode, command === 'build'),
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
'#': path.resolve(__dirname, 'src/types'),
},
},
css: {
preprocessorOptions: {
scss: {
api: 'modern-compiler',
additionalData: scssResources.join(''),
},
},
},
}
})
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/jixinrong/basic.git
git@gitee.com:jixinrong/basic.git
jixinrong
basic
basic
main

搜索帮助

0d507c66 1850385 C8b1a773 1850385