enhance(dev): frontendの検索インデックス作成を単独のコマンドで行えるように (#15653)
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import path from 'path';
|
||||
import pluginReplace from '@rollup/plugin-replace';
|
||||
import pluginVue from '@vitejs/plugin-vue';
|
||||
import { type UserConfig, defineConfig } from 'vite';
|
||||
import { defineConfig } from 'vite';
|
||||
import type { UserConfig } from 'vite';
|
||||
import * as yaml from 'js-yaml';
|
||||
import { promises as fsp } from 'fs';
|
||||
|
||||
@@ -11,12 +12,22 @@ import packageInfo from './package.json' with { type: 'json' };
|
||||
import pluginUnwindCssModuleClassName from './lib/rollup-plugin-unwind-css-module-class-name.js';
|
||||
import pluginJson5 from './vite.json5.js';
|
||||
import pluginCreateSearchIndex from './lib/vite-plugin-create-search-index.js';
|
||||
import type { Options as SearchIndexOptions } from './lib/vite-plugin-create-search-index.js';
|
||||
|
||||
const url = process.env.NODE_ENV === 'development' ? yaml.load(await fsp.readFile('../../.config/default.yml', 'utf-8')).url : null;
|
||||
const host = url ? (new URL(url)).hostname : undefined;
|
||||
|
||||
const extensions = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.json', '.json5', '.svg', '.sass', '.scss', '.css', '.vue'];
|
||||
|
||||
/**
|
||||
* 検索インデックスの生成設定
|
||||
*/
|
||||
export const searchIndexes = [{
|
||||
targetFilePaths: ['src/pages/settings/*.vue'],
|
||||
exportFilePath: './src/utility/autogen/settings-search-index.ts',
|
||||
verbose: process.env.FRONTEND_SEARCH_INDEX_VERBOSE === 'true',
|
||||
}] satisfies SearchIndexOptions[];
|
||||
|
||||
/**
|
||||
* Misskeyのフロントエンドにバンドルせず、CDNなどから別途読み込むリソースを記述する。
|
||||
* CDNを使わずにバンドルしたい場合、以下の配列から該当要素を削除orコメントアウトすればOK
|
||||
@@ -84,11 +95,7 @@ export function getConfig(): UserConfig {
|
||||
},
|
||||
|
||||
plugins: [
|
||||
pluginCreateSearchIndex({
|
||||
targetFilePaths: ['src/pages/settings/*.vue'],
|
||||
exportFilePath: './src/utility/autogen/settings-search-index.ts',
|
||||
verbose: process.env.FRONTEND_SEARCH_INDEX_VERBOSE === 'true',
|
||||
}),
|
||||
...searchIndexes.map(options => pluginCreateSearchIndex(options)),
|
||||
pluginVue(),
|
||||
pluginUnwindCssModuleClassName(),
|
||||
pluginJson5(),
|
||||
|
||||
Reference in New Issue
Block a user