Files
AIProd/nuxt.config.js
2025-11-13 11:23:08 +08:00

139 lines
5.6 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export default {
/**
*
ssr: true + target: 'server' → SSR
ssr: true + target: 'static' → 静态生成SSG
ssr: false → SPA 模式
*/
ssr: true,
target: 'server',
server: {
host: '0.0.0.0', // 允许外部访问,默认是 localhost (127.0.0.1)
port: 3000 // 可选:指定端口号,默认是 3000
},
// publicPath: process.env.NUXT_ENV_PUBLIC_PATH || '/', //服务器资源路径是否有前缀
loading: false, //是否在路由切换或者asyncData/Fetch异步请求期间出现进度条 可自定义详情见https://v2.nuxt.com/docs/features/loading#loading
// Global page headers: https://go.nuxtjs.dev/config-head
//全局配置项,设置一些基础不会变动的东西
head: {
title: 'AIProdLaunch', //设置标签页名字
htmlAttrs: {
lang: 'zh-CN' //设置语言为中文 英文en
},
meta: [
{ charset: 'utf-8' }, //字符集
{ name: 'viewport', content: 'width=device-width, initial-scale=1' }, //完美视口
{ hid: 'description', name: 'description', content: '网站的默认描述' }, //设置描述
{ hid: 'keywords', name: 'keywords', content: 'default' }, //设置关键词
{ name: 'format-detection', content: 'telephone=no' },
{ property: 'og:type', content: 'website' }, // 分享在平台时告诉平台这是网站类型的页面
{ property: 'og:site_name', content: '我的网站' }, //分享在平台时告诉平台这个页面属于哪个网站
{ property: 'og:image', content: 'https://www.example.com/logo.png' } //定义网页在分享时的描述信息
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/logo.png' }
]
},
// 设置页面级或者layouts的head供参考
// head() {
// return {
// title: '关于我们',
// meta: [
// { hid: 'description', name: 'description', content: '默认描述' },
// { hid: 'keywords', name: 'keywords', content: 'example' },
// { property: 'og:title', content: '关于我们 - 我的网站' }, //定义网页在分享时的标题
// { property: 'og:description', content: '这是关于我们的详细信息' } //定义网页在分享时的描述信息
// ]
// }
// }
// Global CSS: https://go.nuxtjs.dev/config-css
css: [
'normalize.css/normalize.css', // 引入
'@/styles/index.scss', //引入全局样式
'@/styles/text.scss',
'@/styles/flex.scss',
'@/styles/article.scss',
'@/styles/font.scss',
],
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [
'@/plugins/router.js', //给路由进行全局路由配置
'@/plugins/axios.js', //设置请求和拦截响应器
'@/plugins/api.js', //将api注入到全局
'@/plugins/element.js',
'@/plugins/global-function.js',
],
// Auto import components: https://go.nuxtjs.dev/config-components
components: true,
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: [
'@nuxtjs/style-resources' //导入样式引入模块
],
styleResources: {
scss: [
'@/styles/variables.scss', //全局变量 、全局混入 、全局函数等放这里全局引入
'@/styles/mixins.scss'
]
},
// Modules: https://go.nuxtjs.dev/config-modules
modules: [
'@nuxtjs/router', //导入路由模块不使用默认的路由使用自己写的路由路由写在router.js里面
'cookie-universal-nuxt', //导入cookie模块能够得到$cookie
'@nuxtjs/axios', //导入nuxtjs/axios模块能够得到$axios
['@nuxtjs/dotenv', { filename: `.env.${process.env.NODE_ENV}` }], //导入模块,能够使之读取环境变量
],
routerModule: {
keepDefaultRouter: false //true:保留默认路由,和默认路由合并 false不保留默认路由完全使用router.js里面的路由
},
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {
postcss: {
plugins: {
'postcss-px-to-viewport': {
unitToConvert: 'px', // 需要转换的单位
viewportWidth: 1920, // 设计稿基准宽度1470px
unitPrecision: 5, // 转换后的小数位数
propList: ['*'], // 转换所有属性
viewportUnit: 'vw', // 转换后的单位
fontViewportUnit: 'vw', // 字体单位也使用 vw
selectorBlackList: [], // 不转换的选择器
minPixelValue: 1, // 小于等于 1px 不转换
mediaQuery: false, // 不转换媒体查询中的 px
replace: true, // 直接替换原属性
exclude: [/node_modules/], // 忽略 node_modules
landscape: false // 不生成横屏适配
}
}
}
},
axios: {
baseURL: process.env.NUXT_ENV_BASE_API || 'https://client-api.aiprodlaunch.com', // API 根地址
credentials: true, // 是否跨域请求时携带 cookie
timeout: 30000, // 请求超时时间ms
// proxy:true, //开启代理
},
//代理
// proxy: {
// '/api': { // 需要转发代理的请求前缀
// target: 'http://app.topv100.com:10041', // 代理的目标地址
// pathRewrite: { '^/api/': '' }, // 重写路径:去掉 /api 前缀
// changeOrigin: true // 是否改变请求源
// },
// }
}