Hangar/frontend/nuxt.config.ts

207 lines
6.3 KiB
TypeScript
Raw Normal View History

2021-01-31 10:00:11 +08:00
import { NuxtConfig } from '@nuxt/types';
2021-03-28 06:41:20 +08:00
import colors from 'vuetify/lib/util/colors';
2021-01-31 10:00:11 +08:00
2021-01-23 06:36:52 +08:00
import en from './locales/en';
import fr from './locales/fr';
import zh from './locales/zh_hans';
2021-01-21 11:36:18 +08:00
2021-04-04 07:53:58 +08:00
require('events').EventEmitter.defaultMaxListeners = 20;
2021-01-21 11:36:18 +08:00
require('dotenv').config();
2021-02-08 05:36:36 +08:00
const proxyHost = process.env.proxyHost || 'http://localhost:8080';
2021-02-08 06:06:06 +08:00
const authHost = process.env.authHost || 'http://localhost:8000';
2021-06-07 05:45:56 +08:00
const lazyAuthHost = process.env.lazyAuthHost || 'http://localhost:8000';
2021-03-16 03:31:16 +08:00
const publicHost = process.env.PUBLIC_HOST || 'http://localhost:3000';
2021-02-08 07:02:17 +08:00
const host = process.env.host || 'localhost';
2021-03-17 01:43:58 +08:00
const nodeEnv = process.env.NODE_ENV;
2021-06-07 05:45:56 +08:00
// noinspection JSUnusedGlobalSymbols
2021-01-21 11:36:18 +08:00
export default {
telemetry: false,
modern: 'server',
// PWA module configuration: https://go.nuxtjs.dev/pwa
pwa: {
manifest: {
name: 'Hangar | PaperMC',
short_name: 'Hangar',
description: 'Plugin repository for Paper plugins and more!',
lang: 'en',
},
},
2021-01-21 11:36:18 +08:00
// Global page headers: https://go.nuxtjs.dev/config-head
head: {
2021-03-29 04:10:41 +08:00
htmlAttrs: {
dir: 'ltr',
},
titleTemplate: (titleChunk) => (titleChunk ? `${titleChunk} | Hangar` : 'Hangar'),
2021-01-21 11:36:18 +08:00
meta: [
{ hid: 'charset', charset: 'utf-8' },
2021-01-21 11:36:18 +08:00
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ property: 'twitter:site', name: 'twitter:site', hid: 'twitter:site', content: 'hangar' },
{ property: 'twitter:card', name: 'twitter:card', hid: 'twitter:card', content: 'summary' },
2021-01-21 11:36:18 +08:00
],
noscript: [{ innerHTML: 'We are sorry, but Hangar requires JavaScript to work properly.' }],
2021-01-21 11:36:18 +08:00
},
2021-03-17 01:43:58 +08:00
env: {
proxyHost,
authHost,
2021-06-07 05:45:56 +08:00
lazyAuthHost,
2021-03-17 01:43:58 +08:00
publicHost,
host,
nodeEnv,
},
2021-01-21 11:36:18 +08:00
// Global CSS: https://go.nuxtjs.dev/config-css
2021-02-12 11:33:01 +08:00
css: ['~/assets/main.scss'],
2021-01-21 11:36:18 +08:00
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: ['~/plugins/api.ts', '~/plugins/utils.ts', '~/plugins/auth.ts', '~/plugins/perms.ts', '~/plugins/seo.ts'],
2021-01-21 11:36:18 +08:00
// Auto import components: https://go.nuxtjs.dev/config-components
components: false,
2021-01-21 11:36:18 +08:00
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: [
// https://go.nuxtjs.dev/typescript
'@nuxt/typescript-build',
// https://go.nuxtjs.dev/vuetify
'@nuxtjs/vuetify',
2021-01-31 10:00:11 +08:00
// https://go.nuxtjs.dev/eslint
'@nuxtjs/eslint-module',
2021-02-06 16:29:16 +08:00
// https://go.nuxtjs.dev/pwa
'@nuxtjs/pwa',
2021-01-22 04:32:08 +08:00
'@nuxtjs/dotenv',
2021-01-21 11:36:18 +08:00
],
// Modules: https://go.nuxtjs.dev/config-modules
modules: [
// https://go.nuxtjs.dev/axios
'@nuxtjs/axios',
'cookie-universal-nuxt',
2021-01-22 03:47:58 +08:00
'@nuxtjs/proxy',
2021-01-23 05:06:44 +08:00
'nuxt-i18n',
'@dansmaculotte/nuxt-security',
2021-01-21 11:36:18 +08:00
],
// Axios module configuration: https://go.nuxtjs.dev/config-axios
2021-01-23 13:24:48 +08:00
axios: {},
2021-01-21 11:36:18 +08:00
// Vuetify module configuration: https://go.nuxtjs.dev/config-vuetify
vuetify: {
customVariables: ['~/assets/variables.scss'],
optionsPath: '~/plugins/vuetify.ts',
2021-01-31 01:27:36 +08:00
treeShake: true,
2021-01-21 11:36:18 +08:00
},
// Build Configuration: https://go.nuxtjs.dev/config-build
2021-01-31 01:27:36 +08:00
build: {
2021-02-24 05:40:59 +08:00
transpile: ['lodash-es'],
2021-01-31 01:27:36 +08:00
},
2021-01-22 03:47:58 +08:00
2021-01-22 11:11:24 +08:00
router: {
2021-02-05 08:22:22 +08:00
middleware: ['auth', 'routePermissions'],
2021-01-22 11:11:24 +08:00
},
2021-01-31 03:55:24 +08:00
proxy: [
2021-02-08 06:06:06 +08:00
// backend
proxyHost + '/api/',
proxyHost + '/signup',
proxyHost + '/login',
proxyHost + '/logout',
proxyHost + '/refresh',
proxyHost + '/invalidate',
proxyHost + '/v2/api-docs/',
2021-04-04 07:53:58 +08:00
proxyHost + '/robots.txt',
proxyHost + '/sitemap.xml',
proxyHost + '/global-sitemap.xml',
proxyHost + '/*/sitemap.xml',
2021-04-04 13:17:05 +08:00
proxyHost + '/statusz',
2021-02-08 06:06:06 +08:00
// auth
2021-06-07 05:45:56 +08:00
lazyAuthHost + '/avatar',
2021-01-31 03:55:24 +08:00
],
2021-01-22 03:47:58 +08:00
2021-01-23 05:06:44 +08:00
i18n: {
vueI18nLoader: true,
strategy: 'no_prefix',
defaultLocale: 'en',
locales: [
{ code: 'fr', iso: 'fr-FR', name: 'Français', icon: 'Test' },
{ code: 'en', iso: 'en-US', name: 'English', icon: 'Test' },
{ code: 'zh', iso: 'zh-HANS', name: 'Simplified Chinese', icon: 'Test' },
2021-01-23 05:06:44 +08:00
],
vueI18n: {
locale: 'en',
fallbackLocale: 'en',
messages: {
en,
fr,
zh,
2021-01-23 05:06:44 +08:00
},
},
detectBrowserLanguage: {
useCookie: true,
cookieKey: 'i18n_redirected',
onlyOnRoot: true,
},
2021-01-31 10:00:11 +08:00
},
2021-01-23 05:06:44 +08:00
security: {
dev: true,
hsts: {
maxAge: 15552000,
includeSubDomains: true,
preload: true,
},
2021-04-06 00:49:46 +08:00
csp: {
directives: {
defaultSrc: ["'self'", 'https://google-analytics.com', 'https://fonts.gstatic.com', 'https://fonts.googleapis.com'],
styleSrc: ["'self'", 'https://fonts.googleapis.com', 'cdn.jsdelivr.net', "'unsafe-inline'"],
fontSrc: ['fonts.gstatic.com', 'cdn.jsdelivr.net'],
2021-06-07 05:58:08 +08:00
scriptSrc: ["'self'" /* , "'nonce-{nonce}'" */, "'unsafe-inline'", "'unsafe-eval'", 'https://static.cloudflareinsights.com'],
imgSrc: [
2021-04-06 00:49:46 +08:00
"'self'",
'https://www.google-analytics.com',
'https://www.gravatar.com',
2021-06-07 05:58:08 +08:00
lazyAuthHost,
2021-04-06 00:49:46 +08:00
'data: papermc.io paper.readthedocs.io',
'https:', // ppl can use images in descriptions, we would need an image proxy or smth
],
frameSrc: ["'self'", 'http://localhost/', 'https://papermc.io/'],
manifestSrc: ["'self'"],
connectSrc: ["'self'", 'https://www.google-analytics.com', 'https://stats.g.doubleclick.net'],
mediaSrc: ["'self'"],
objectSrc: ["'none'"],
baseUri: ["'none'"],
2021-04-06 00:49:46 +08:00
},
reportOnly: false,
2021-04-06 00:49:46 +08:00
},
referrer: 'same-origin',
additionalHeaders: true,
2021-04-06 00:49:46 +08:00
},
2021-01-22 03:47:58 +08:00
server: {
port: 3000,
host,
2021-01-22 03:47:58 +08:00
},
2021-01-31 02:50:12 +08:00
loading: {
2021-03-28 06:41:20 +08:00
color: colors.blue.lighten2,
2021-01-31 02:50:12 +08:00
continuous: true,
},
2021-03-16 03:31:16 +08:00
publicRuntimeConfig: {
axios: {
browserBaseURL: publicHost,
},
},
privateRuntimeConfig: {
axios: {
baseURL: proxyHost,
},
},
2021-01-31 10:00:11 +08:00
} as NuxtConfig;