加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
nuxt.config.js 3.22 KB
一键复制 编辑 原始数据 按行查看 历史
yangjing 提交于 2022-02-10 15:07 . fix: 修改配置
// eslint-disable-next-line nuxt/no-cjs-in-config
const path = require('path')
// eslint-disable-next-line nuxt/no-cjs-in-config
const fg = require('fast-glob')
const filePath = fg.sync('./modules/**/route.js', {
deep: 2,
onlyFiles: true,
})
const routes = filePath.reduce((allRoutes, cur) => {
const file = require(cur).default
console.log('cur:',cur)
return allRoutes.concat(file)
}, [])
// 不能以斜杠结尾
const apiServer = (process.env.API_SERVER || '').trim()
const isProd = process.env.MODE === 'prod' || process.env.MODE === 'uat' || process.env.MODE === 'test'
const publicPath = process.env.PUBLIC_PATH || './'
console.log(isProd, publicPath)
let axios = {
proxy: true,
}
// 如果生产指定apiServer, 则使用绝对路径请求api
if (isProd && apiServer) {
axios = {
proxy: false,
baseURL: apiServer
}
}
export default {
mode: 'spa',
ssr: false,
server: {
host: '0.0.0.0',
port: 3600,
},
// env: {
// Mode: process.env.MODE,
// Company_Id: process.env.COMPANY_ID,
// },
// Global page headers: https://go.nuxtjs.dev/config-head
head: {
title: 'h5-front-code',
htmlAttrs: {
lang: 'en'
},
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1, user-scalable=no, viewport-fit=cover' },
{ hid: 'description', name: 'description', content: process.env.npm_package_description || '' },
{ name: 'format-detection', content: 'telephone=no' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
],
script: [
// {
// type: 'text/javascript',
// src: 'https://g.alicdn.com/dingding/dingtalk-jsapi/2.10.3/dingtalk.open.js'
// },
],
},
// Global CSS: https://go.nuxtjs.dev/config-css
css: [
{
src: '~assets/normalize.less',
lang: 'less',
},
{
src: '~/assets/global.less',
lang: 'less',
},
'vant/lib/index.less'
],
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [
'@/plugins/vant'
],
router: {
// base: '/market-web-h5/',
mode: 'hash',
extendRoutes(r, resolve) {
r.unshift({
path: '/',
redirect: '/home'
})
r.unshift(...routes)
},
},
// Auto import components: https://go.nuxtjs.dev/config-components
components: true,
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: [
],
// Modules: https://go.nuxtjs.dev/config-modules
modules: [
],
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {
[isProd ? 'publicPath' : '']: publicPath,
// 提取css到单独link文件
extractCSS: true,
loaders: {
less: {
modifyVars: {
hack: `true; @import "~assets/element-variable.less";`
}
}
},
babel: {
plugins: [
// [
// 'import',
// {
// libraryName: 'vant',
// libraryDirectory: 'es',
// style: true,
// },
// 'vant',
// ],
],
},
},
proxy: {
// 内容中心
"/dxp-domain-cms": {
changeOrigin: true,
target: 'http://127.0.0.1:36001'
},
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化