2023-07-08 10:36:02 +02:00
|
|
|
|
// https://nuxt.com/docs/api/configuration/nuxt-config
|
2023-11-12 07:54:05 +01:00
|
|
|
|
import yaml from '@rollup/plugin-yaml';
|
2023-07-08 10:36:02 +02:00
|
|
|
|
import svgLoader from 'vite-svg-loader';
|
2023-12-02 02:35:35 +01:00
|
|
|
|
import { readFileSync } from 'fs';
|
2023-07-17 18:44:06 +02:00
|
|
|
|
import { genApiTranslationFiles } from './scripts/gen-api-translations';
|
2023-12-12 11:28:20 +01:00
|
|
|
|
import { getOldHubRedirects } from './scripts/get-old-hub-redirects';
|
2023-11-12 07:54:05 +01:00
|
|
|
|
import { genLocalesJson } from './scripts/gen-locales';
|
2023-11-30 23:39:47 +01:00
|
|
|
|
import { getStaticEndpoints } from './scripts/get-static-endpoints';
|
2023-12-12 11:28:20 +01:00
|
|
|
|
import { locales } from './assets/data/locales';
|
2023-11-30 14:43:05 +01:00
|
|
|
|
import type { NuxtConfig } from 'nuxt/schema';
|
2023-07-08 10:36:02 +02:00
|
|
|
|
|
2023-07-10 19:54:13 +02:00
|
|
|
|
// 公開時のドメイン(末尾スラッシュなし)
|
2023-12-23 16:42:41 +01:00
|
|
|
|
const baseUrl =
|
|
|
|
|
process.env.NODE_ENV == 'development'
|
|
|
|
|
? 'http://localhost:3000'
|
|
|
|
|
: 'https://misskey-hub.net';
|
2023-07-10 19:54:13 +02:00
|
|
|
|
|
2023-12-18 09:43:48 +01:00
|
|
|
|
// リポジトリURL(末尾スラッシュなし)
|
|
|
|
|
const repositoryUrl = 'https://github.com/misskey-dev/misskey-hub-next';
|
|
|
|
|
|
2023-12-12 11:28:20 +01:00
|
|
|
|
// 言語定義は /assets/data/locales.ts に移動しました
|
2023-07-11 19:19:32 +02:00
|
|
|
|
|
2023-11-30 14:43:05 +01:00
|
|
|
|
function getRouteRules(): NuxtConfig['routeRules'] {
|
|
|
|
|
// 言語ごとに割り当てる必要のないRouteRules
|
|
|
|
|
const staticRules: NuxtConfig['routeRules'] = {
|
|
|
|
|
'/ja/blog/**': { isr: true },
|
2023-11-30 23:39:47 +01:00
|
|
|
|
'/ns/': { prerender: true },
|
2023-11-30 14:43:05 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// それぞれの言語について割り当てる必要のあるRouteRules
|
|
|
|
|
const localeBasedRules: NuxtConfig['routeRules'] = {
|
2023-12-02 11:19:15 +01:00
|
|
|
|
// リリースページはどうせアクセス集中するので先に作っておく
|
|
|
|
|
'/docs/releases/': { prerender: true },
|
2023-11-30 14:43:05 +01:00
|
|
|
|
'/docs/**': { isr: true },
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-30 23:39:47 +01:00
|
|
|
|
// 静的ページをすべて追加
|
|
|
|
|
getStaticEndpoints().forEach((route) => {
|
|
|
|
|
if (!route.includes('ns')) {
|
|
|
|
|
localeBasedRules[route] = { prerender: true };
|
|
|
|
|
staticRules[route] = { prerender: true };
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2023-11-30 14:43:05 +01:00
|
|
|
|
// 言語ごとにすべて割り当てていく
|
|
|
|
|
const _localeBasedRules: NuxtConfig['routeRules'] = {};
|
|
|
|
|
const localeCodes = locales.map((v) => v.code);
|
|
|
|
|
Object.keys(localeBasedRules).forEach((route) => {
|
|
|
|
|
localeCodes.forEach((code) => {
|
|
|
|
|
_localeBasedRules[`/${code}${route}`] = localeBasedRules[route];
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
...staticRules,
|
|
|
|
|
..._localeBasedRules,
|
2023-12-23 17:05:41 +01:00
|
|
|
|
...((process.env.VERCEL !== '1') ? getOldHubRedirects('nitro') : {}),
|
2023-11-30 14:43:05 +01:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-08 10:36:02 +02:00
|
|
|
|
export default defineNuxtConfig({
|
2023-07-10 19:54:13 +02:00
|
|
|
|
runtimeConfig: {
|
|
|
|
|
public: {
|
|
|
|
|
baseUrl,
|
2023-12-18 09:43:48 +01:00
|
|
|
|
repositoryUrl,
|
2023-11-25 17:48:16 +01:00
|
|
|
|
locales,
|
2023-07-10 19:54:13 +02:00
|
|
|
|
}
|
|
|
|
|
},
|
2023-07-08 10:36:02 +02:00
|
|
|
|
css: [
|
2023-07-10 19:54:13 +02:00
|
|
|
|
"github-markdown-css/github-markdown.css",
|
2023-10-29 14:02:27 +01:00
|
|
|
|
"@/assets/css/nprogress.css",
|
2023-07-08 10:36:02 +02:00
|
|
|
|
"@/assets/css/tailwind.css",
|
2023-12-21 11:01:37 +01:00
|
|
|
|
"@/assets/css/mfm.scss",
|
2023-07-09 11:58:53 +02:00
|
|
|
|
"@/assets/css/bootstrap-forms.scss",
|
2023-07-08 10:36:02 +02:00
|
|
|
|
],
|
|
|
|
|
modules: [
|
|
|
|
|
'@nuxt/content',
|
|
|
|
|
'@nuxtjs/i18n',
|
2023-07-08 19:23:27 +02:00
|
|
|
|
'@nuxtjs/color-mode',
|
2023-07-08 10:36:02 +02:00
|
|
|
|
],
|
|
|
|
|
app: {
|
|
|
|
|
head: {
|
|
|
|
|
link: [
|
|
|
|
|
{ rel: 'stylesheet', href: '/fonts/fonts.css' },
|
2023-12-04 07:50:06 +01:00
|
|
|
|
{ rel: 'apple-touch-icon', href: '/img/icons/apple-touch-icon.png' },
|
2023-12-01 17:20:08 +01:00
|
|
|
|
{ rel: 'shortcut icon', type: 'image/vnd.microsoft.icon', href: '/favicon.ico' },
|
|
|
|
|
{ rel: 'icon', type: 'image/vnd.microsoft.icon', href: '/favicon.ico' },
|
2023-12-22 12:28:30 +01:00
|
|
|
|
{ rel: 'me', href: 'https://misskey.io/@misskey_hub_deploy' },
|
2023-07-08 10:36:02 +02:00
|
|
|
|
],
|
2023-12-01 17:20:08 +01:00
|
|
|
|
meta: [
|
|
|
|
|
{ name: 'twitter:card', content: 'summary_large_image' },
|
|
|
|
|
]
|
2023-07-08 10:36:02 +02:00
|
|
|
|
},
|
|
|
|
|
},
|
2023-07-10 19:54:13 +02:00
|
|
|
|
content: {
|
|
|
|
|
navigation: {
|
|
|
|
|
fields: [
|
|
|
|
|
'date',
|
2023-07-15 10:32:48 +02:00
|
|
|
|
'description',
|
2023-07-10 19:54:13 +02:00
|
|
|
|
]
|
2023-07-17 18:44:06 +02:00
|
|
|
|
},
|
|
|
|
|
highlight: {
|
|
|
|
|
theme: {
|
|
|
|
|
// Default theme (same as single string)
|
|
|
|
|
default: 'github-light',
|
|
|
|
|
// Theme used if `html.dark`
|
|
|
|
|
dark: 'github-dark',
|
|
|
|
|
},
|
2023-12-02 02:35:35 +01:00
|
|
|
|
preload: [
|
|
|
|
|
'ini', 'sql', 'yml', 'nginx', 'bash',
|
|
|
|
|
JSON.parse(readFileSync('./node_modules/aiscript-vscode/aiscript/syntaxes/aiscript.tmLanguage.json', { encoding: 'utf-8' })),
|
|
|
|
|
],
|
2023-07-17 18:44:06 +02:00
|
|
|
|
},
|
2023-07-10 19:54:13 +02:00
|
|
|
|
},
|
2023-07-08 10:36:02 +02:00
|
|
|
|
i18n: {
|
2023-07-10 19:54:13 +02:00
|
|
|
|
baseUrl,
|
2023-07-08 10:36:02 +02:00
|
|
|
|
vueI18n: './i18n.config.ts',
|
2023-07-11 19:19:32 +02:00
|
|
|
|
locales,
|
2023-11-12 07:54:05 +01:00
|
|
|
|
lazy: true,
|
|
|
|
|
langDir: 'locales_dist',
|
2023-07-08 10:36:02 +02:00
|
|
|
|
defaultLocale: 'ja',
|
2023-12-22 14:33:35 +01:00
|
|
|
|
// ▼ Defaultルートは、nitroプラグインでオーバーライドする
|
2023-12-22 15:53:24 +01:00
|
|
|
|
// リンクはuseGLocalePath(ラッパー)を使う
|
|
|
|
|
strategy: 'prefix_and_default',
|
2023-09-09 08:06:22 +02:00
|
|
|
|
trailingSlash: true,
|
2023-07-08 10:36:02 +02:00
|
|
|
|
},
|
2023-07-08 19:23:27 +02:00
|
|
|
|
colorMode: {
|
|
|
|
|
classSuffix: '',
|
|
|
|
|
},
|
2023-07-08 10:36:02 +02:00
|
|
|
|
postcss: {
|
|
|
|
|
plugins: {
|
|
|
|
|
tailwindcss: {},
|
|
|
|
|
autoprefixer: {},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
alias: {
|
|
|
|
|
'bi': 'bootstrap-icons/icons',
|
|
|
|
|
},
|
|
|
|
|
vite: {
|
|
|
|
|
plugins: [
|
2023-11-12 07:54:05 +01:00
|
|
|
|
yaml(),
|
2023-07-08 10:36:02 +02:00
|
|
|
|
svgLoader({
|
|
|
|
|
defaultImport: 'component',
|
|
|
|
|
svgoConfig: {
|
|
|
|
|
plugins: [
|
|
|
|
|
{
|
|
|
|
|
name: 'preset-default',
|
|
|
|
|
params: {
|
|
|
|
|
overrides: {
|
|
|
|
|
removeViewBox: false,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}),
|
2023-11-12 07:54:05 +01:00
|
|
|
|
],
|
2023-07-08 10:36:02 +02:00
|
|
|
|
},
|
|
|
|
|
nitro: {
|
2023-12-12 14:46:53 +01:00
|
|
|
|
vercel: {
|
|
|
|
|
config: {
|
|
|
|
|
routes: [
|
2023-12-23 17:00:23 +01:00
|
|
|
|
...getOldHubRedirects('vercel'),
|
2023-12-12 14:46:53 +01:00
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
},
|
2023-07-08 10:36:02 +02:00
|
|
|
|
plugins: [
|
|
|
|
|
'@/server/plugins/appendComment.ts',
|
2023-09-29 13:30:27 +02:00
|
|
|
|
'@/server/plugins/i18nRedirector.ts',
|
2023-07-08 10:36:02 +02:00
|
|
|
|
],
|
2023-07-13 18:27:48 +02:00
|
|
|
|
},
|
2023-07-17 18:44:06 +02:00
|
|
|
|
hooks: {
|
2023-11-12 07:54:05 +01:00
|
|
|
|
'build:before': (...args) => {
|
|
|
|
|
genApiTranslationFiles(...args);
|
|
|
|
|
genLocalesJson(...args);
|
|
|
|
|
},
|
2023-07-17 18:44:06 +02:00
|
|
|
|
},
|
2023-07-13 18:27:48 +02:00
|
|
|
|
experimental: {
|
|
|
|
|
inlineSSRStyles: false,
|
2023-09-28 12:29:11 +02:00
|
|
|
|
componentIslands: true,
|
2023-07-13 18:27:48 +02:00
|
|
|
|
},
|
2023-11-30 14:43:05 +01:00
|
|
|
|
routeRules: getRouteRules(),
|
|
|
|
|
});
|