2020-06-22 17:13:42 +08:00
|
|
|
|
import appConfig from './config/app.config'
|
|
|
|
|
import apiConfig from './config/api.config'
|
2020-08-11 14:42:45 +08:00
|
|
|
|
import {isDevMode} from './environment'
|
2020-10-18 18:57:17 +08:00
|
|
|
|
|
2020-08-12 17:22:23 +08:00
|
|
|
|
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin')
|
2020-06-22 17:13:42 +08:00
|
|
|
|
|
2020-06-19 17:10:44 +08:00
|
|
|
|
export default {
|
|
|
|
|
/*
|
|
|
|
|
** Nuxt rendering mode
|
|
|
|
|
** See https://nuxtjs.org/api/configuration-mode
|
|
|
|
|
*/
|
2020-10-18 18:57:17 +08:00
|
|
|
|
ssr: true,
|
2020-06-19 17:10:44 +08:00
|
|
|
|
/*
|
2020-06-21 21:56:34 +08:00
|
|
|
|
** Render configuration
|
|
|
|
|
*/
|
|
|
|
|
render: {
|
2020-07-31 16:17:12 +08:00
|
|
|
|
csp: false
|
2020-06-21 21:56:34 +08:00
|
|
|
|
},
|
2020-06-22 17:13:42 +08:00
|
|
|
|
modern: true,
|
|
|
|
|
dev: isDevMode,
|
2020-06-21 21:56:34 +08:00
|
|
|
|
env: {
|
2020-06-22 17:13:42 +08:00
|
|
|
|
BASE: apiConfig.BASE,
|
|
|
|
|
HOST_URL: apiConfig.SOCKET
|
|
|
|
|
},
|
|
|
|
|
cache: {
|
|
|
|
|
max: 100,
|
|
|
|
|
maxAge: 1000 * 60 * 15
|
2020-06-21 21:56:34 +08:00
|
|
|
|
},
|
|
|
|
|
/*
|
2020-06-19 17:10:44 +08:00
|
|
|
|
** Headers of the page
|
|
|
|
|
** See https://nuxtjs.org/api/configuration-head
|
|
|
|
|
*/
|
|
|
|
|
head: {
|
2020-06-22 17:13:42 +08:00
|
|
|
|
title: appConfig.meta.title,
|
2020-06-19 17:10:44 +08:00
|
|
|
|
meta: [
|
2020-06-30 17:50:32 +08:00
|
|
|
|
{charset: 'utf-8'},
|
|
|
|
|
{name: 'viewport', content: 'width=device-width, initial-scale=1'},
|
|
|
|
|
{hid: 'keywords', name: 'keywords', content: appConfig.meta.keywords},
|
|
|
|
|
{hid: 'description', name: 'description', content: appConfig.meta.description}
|
2020-06-19 17:10:44 +08:00
|
|
|
|
],
|
|
|
|
|
link: [
|
2020-06-30 17:50:32 +08:00
|
|
|
|
{rel: 'icon', type: 'image/x-icon', href: '/favicon.ico'}
|
2020-06-19 17:10:44 +08:00
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
/*
|
|
|
|
|
** Global CSS
|
|
|
|
|
*/
|
|
|
|
|
css: [
|
2020-11-09 22:02:00 +08:00
|
|
|
|
'element-ui/lib/theme-chalk/index.css',
|
2020-06-19 17:10:44 +08:00
|
|
|
|
],
|
|
|
|
|
/*
|
|
|
|
|
** Plugins to load before mounting the App
|
|
|
|
|
** https://nuxtjs.org/guide/plugins
|
|
|
|
|
*/
|
|
|
|
|
plugins: [
|
2020-08-02 19:25:40 +08:00
|
|
|
|
{src: '~/plugins/avataaars/generator/generateAvatar'},
|
2020-07-31 16:17:12 +08:00
|
|
|
|
{src: '~/plugins/extend'},
|
|
|
|
|
{src: '~/plugins/axios'},
|
|
|
|
|
{src: '~/plugins/element-ui'},
|
2023-05-26 15:34:59 +08:00
|
|
|
|
{src: '~/plugins/vditor', ssr: false},
|
2023-09-08 18:15:07 +08:00
|
|
|
|
{src: '~/plugins/vue-sse'},
|
|
|
|
|
{src: '~/plugins/vue-cropper', ssr: false}
|
2020-06-19 17:10:44 +08:00
|
|
|
|
],
|
|
|
|
|
/*
|
|
|
|
|
** Nuxt.js dev-modules
|
|
|
|
|
*/
|
2020-06-30 17:50:32 +08:00
|
|
|
|
buildModules: [],
|
2020-06-19 17:10:44 +08:00
|
|
|
|
/*
|
|
|
|
|
** Nuxt.js modules
|
|
|
|
|
*/
|
|
|
|
|
modules: [
|
2020-07-31 16:17:12 +08:00
|
|
|
|
'@nuxtjs/axios',
|
|
|
|
|
'@nuxtjs/proxy',
|
2023-08-31 22:03:44 +08:00
|
|
|
|
'@nuxtjs/auth-next',
|
|
|
|
|
'@nuxtjs/device',
|
2020-06-19 17:10:44 +08:00
|
|
|
|
],
|
2022-10-27 23:22:46 +08:00
|
|
|
|
auth: {
|
|
|
|
|
redirect: {
|
|
|
|
|
login: '/login',
|
|
|
|
|
logout: false,
|
2022-10-29 22:18:17 +08:00
|
|
|
|
home: '/'
|
2022-10-27 23:22:46 +08:00
|
|
|
|
},
|
|
|
|
|
strategies: {
|
|
|
|
|
local: {
|
|
|
|
|
// scope: true,
|
|
|
|
|
scheme: 'refresh',
|
|
|
|
|
token: {
|
|
|
|
|
property: 'token',
|
|
|
|
|
global: true,
|
|
|
|
|
maxAge: 60 * 15,
|
|
|
|
|
// required: true,
|
|
|
|
|
type: false
|
|
|
|
|
},
|
|
|
|
|
refreshToken: {
|
|
|
|
|
property: 'refreshToken',
|
|
|
|
|
data: 'refreshToken',
|
|
|
|
|
maxAge: 60 * 60 * 2
|
|
|
|
|
},
|
|
|
|
|
user: {
|
|
|
|
|
property: 'user',
|
|
|
|
|
autoFetch: false
|
|
|
|
|
},
|
|
|
|
|
endpoints: {
|
2023-05-26 15:34:59 +08:00
|
|
|
|
login: {url: '/api/auth/login', method: 'post'},
|
|
|
|
|
logout: {url: '/api/auth/logout', method: 'post'},
|
|
|
|
|
refresh: {url: '/api/auth/refresh-token', method: 'post'},
|
|
|
|
|
user: {url: '/api/auth/user', method: 'get'}
|
2022-10-27 23:22:46 +08:00
|
|
|
|
},
|
|
|
|
|
autoLogout: false
|
|
|
|
|
}
|
2023-05-26 15:34:59 +08:00
|
|
|
|
},
|
|
|
|
|
plugins: [{src: '~/plugins/axios', ssr: true}]
|
2022-10-27 23:22:46 +08:00
|
|
|
|
},
|
2020-07-31 16:17:12 +08:00
|
|
|
|
axios: {
|
|
|
|
|
proxy: true // 开启proxy
|
|
|
|
|
},
|
|
|
|
|
proxy: [ //proxy配置
|
|
|
|
|
['/api', {
|
2020-07-31 17:40:17 +08:00
|
|
|
|
target: apiConfig.BASE, //api请求路径
|
2023-09-08 18:15:07 +08:00
|
|
|
|
pathRewrite: {'^/api': isDevMode ? '/api' : '/api'} //重定向请求路径,防止路由、api路径的冲突
|
2021-03-25 21:48:05 +08:00
|
|
|
|
}],
|
|
|
|
|
['/ws', {
|
|
|
|
|
target: apiConfig.BASE //api请求路径
|
2020-07-31 16:17:12 +08:00
|
|
|
|
}]
|
|
|
|
|
],
|
2020-06-19 17:10:44 +08:00
|
|
|
|
/*
|
|
|
|
|
** Build configuration
|
|
|
|
|
** See https://nuxtjs.org/api/configuration-build/
|
|
|
|
|
*/
|
|
|
|
|
build: {
|
2023-04-06 19:31:55 +08:00
|
|
|
|
transpile: [/^element-ui/,'defu'],
|
2020-08-12 17:22:23 +08:00
|
|
|
|
optimization: {
|
|
|
|
|
splitChunks: {
|
|
|
|
|
minSize: 10000,
|
|
|
|
|
maxSize: 250000
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
extend(config, ctx) {
|
|
|
|
|
config.plugins.unshift(new LodashModuleReplacementPlugin())
|
|
|
|
|
// rules[2].use[0] is babel-loader
|
2021-08-12 11:35:53 +08:00
|
|
|
|
config.module.rules.push({test: /\.txt$/, use: 'raw-loader'})
|
2020-08-12 17:22:23 +08:00
|
|
|
|
config.module.rules[2].use[0].options.plugins = ['lodash']
|
2021-08-12 11:35:53 +08:00
|
|
|
|
},
|
|
|
|
|
babel: {
|
2023-05-26 15:34:59 +08:00
|
|
|
|
presets({envName}) {
|
2021-08-12 11:35:53 +08:00
|
|
|
|
return [
|
|
|
|
|
[
|
|
|
|
|
'@nuxt/babel-preset-app',
|
|
|
|
|
{
|
|
|
|
|
loose: true
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
}
|
2020-08-12 17:22:23 +08:00
|
|
|
|
}
|
2020-06-19 17:10:44 +08:00
|
|
|
|
}
|
|
|
|
|
}
|