1 Star 0 Fork 29

Vimin/BuildAdminNuxt

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
nuxt.config.ts 1.96 KB
一键复制 编辑 原始数据 按行查看 历史
妙码生花 提交于 2023-02-16 02:26 . refactor:国际化实现方案重构
import { loadEnv } from 'vite'
import { buildLocalIconNames } from './assets/script/buildIcons'
let envScript = 'development'
if (['build', 'generate'].includes(process.env.npm_lifecycle_event ?? '')) {
envScript = 'production'
}
const envData = loadEnv(envScript, '')
if (!envData.VITE_API_BASE_URL) {
throw new Error('请先于 .env.production 文件内,配置生产环境的 VITE_API_BASE_URL')
}
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
app: {
head: {
link: [{ rel: 'stylesheet', crossorigin: 'anonymous', href: '//cdn.bootcdn.net/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css' }],
},
},
runtimeConfig: {
public: {
env: envData.VITE_ENV,
apiBaseUrl: envData.VITE_API_BASE_URL,
},
},
typescript: {
shim: false,
},
modules: ['@vueuse/nuxt', '@unocss/nuxt', '@element-plus/nuxt', '@pinia/nuxt', '@pinia-plugin-persistedstate/nuxt', 'nuxt-icons'],
imports: {
dirs: ['stores'],
},
hooks: {
'build:before': () => {
buildLocalIconNames()
},
},
vite: {
resolve: {
alias: {
'vue-i18n': envData.VITE_ENV == 'production' ? 'vue-i18n/dist/vue-i18n.cjs.prod.js' : 'vue-i18n/dist/vue-i18n.cjs.js',
},
},
},
// 直接加载el的css以供随时使用 --el 开头的css类
css: ['element-plus/dist/index.css', 'element-plus/theme-chalk/display.css', '~/assets/scss/index.scss'],
vueuse: {
ssrHandlers: true,
},
unocss: {
uno: true,
attributify: true,
icons: {
scale: 1.2,
},
},
elementPlus: {
icon: false,
},
pinia: {
autoImports: ['defineStore', 'acceptHMRUpdate'],
disableVuex: true,
},
// https://github.com/unocss/unocss/issues/2113
sourcemap: {
server: true,
client: false,
},
})
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/Vimin/build-admin-nuxt.git
git@gitee.com:Vimin/build-admin-nuxt.git
Vimin
build-admin-nuxt
BuildAdminNuxt
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385