This repository has been archived by the owner on May 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nuxt.config.ts
156 lines (135 loc) · 3.69 KB
/
nuxt.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import fs from 'node:fs'
import { execSync } from 'node:child_process'
import { networkInterfaces } from 'node:os'
import { NuxtConfig } from '@nuxt/types'
function getIpAddress() {
const nets = networkInterfaces()
const net = nets.en0?.find((v) => v.family === 'IPv4')
return net ? net.address : undefined
}
const hostname = getIpAddress() || 'localhost'
const host = process.env.HOST || hostname
const port = process.env.PORT || 3000
const apiHost = process.env.API_HOST || hostname
const apiPort = process.env.API_PORT || 8000
const apiProtocol = process.env.API_PROTOCOL || 'http'
const apiBaseURL = `${apiProtocol}://${apiHost}:${apiPort}/`
console.log(`API base URL: ${apiBaseURL}`)
const baseURL = process.env.NODE_ENV === 'production' ? '/' : apiBaseURL
execSync(
'npx npm-license-crawler --dependencies --production --onlyDirectDependencies --omitVersion --json ./src/licenses.json'
)
const licenses = JSON.parse(fs.readFileSync('./src/licenses.json', 'utf8'))
const config: NuxtConfig = {
srcDir: 'src/',
ssr: false,
target: 'static',
head: {
titleTemplate: 'my-pixiv',
title: 'my-pixiv',
htmlAttrs: {
lang: 'ja',
},
meta: [
// eslint-disable-next-line unicorn/text-encoding-identifier-case
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: '' },
{ name: 'format-detection', content: 'telephone=no' },
{ name: 'mobile-web-app-capable', content: 'yes' },
{ name: 'apple-mobile-web-app-capable', content: 'yes' },
{ name: 'apple-mobile-web-app-status-bar-style', content: 'black' },
{ name: 'apple-mobile-web-app-title', content: 'my-pixiv' },
{ name: 'robots', content: 'noindex, nofollow' },
],
link: [
{
rel: 'apple-touch-icon',
sizes: '180x180',
href: '/favicons/apple-touch-icon.png',
},
{
rel: 'icon',
type: 'image/png',
sizes: '32x32',
href: '/favicons/favicon-32x32.png',
},
{
rel: 'icon',
type: 'image/png',
sizes: '16x16',
href: '/favicons/favicon-16x16.png',
},
{
rel: 'mask-icon',
href: '/favicons/safari-pinned-tab.svg',
color: '#ffb41d',
},
{
rel: 'shortcut icon',
type: 'image/x-icon',
href: '/favicons/favicon.ico',
},
],
},
pwa: {
manifest: {
lang: 'ja',
name: 'my-pixiv',
short_name: 'my-pixiv',
description: 'pixiv client for myself.',
display: 'standalone',
theme_color: '#0097fa',
background_color: '#fff',
orientation: 'portrait',
scope: '/',
start_url: '/',
},
},
css: ['@mdi/font/css/materialdesignicons.css', '@/assets/scroll.css'],
plugins: [
{ src: 'plugins/settings.ts', ssr: false },
{ src: 'plugins/websocket.ts', ssr: false },
{ src: 'plugins/fetcher.ts', ssr: false },
{ src: 'plugins/workbox.ts', mode: 'client' },
],
components: false,
buildModules: [
'@nuxt/typescript-build',
'@nuxtjs/stylelint-module',
'@nuxtjs/vuetify',
'@nuxtjs/pwa',
'nuxt-typed-vuex',
],
modules: ['@nuxtjs/axios'],
axios: {
baseURL,
},
publicRuntimeConfig: {
baseURL,
appVersion: process.env.npm_package_version,
os: process.platform,
nodeVersion: process.version,
environment: process.env.NODE_ENV,
licenses,
},
vuetify: {
customVariables: [],
theme: {
dark: false,
},
defaultAssets: {
icons: false,
},
},
server: {
host,
port,
},
build: {
parallel: true,
cache: true,
postcss: false,
},
}
export default config