-
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathvite.config.ts
More file actions
46 lines (40 loc) · 1.07 KB
/
Copy pathvite.config.ts
File metadata and controls
46 lines (40 loc) · 1.07 KB
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
import { defineConfig } from 'vite';
import path from 'path';
import { glob } from 'glob';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// プロジェクト内のHTMLファイルを自動的に取得
const getHtmlEntries = () => {
const htmlFiles = glob.sync('**/*.html', {
ignore: ['node_modules/**', 'dist/**', '.git/**'],
});
return Object.fromEntries(
htmlFiles.map((file) => {
// ファイル名(パスを含む)をキーにする(例: "editor/index")
const key = file.replace(/\.html$/, '');
return [key, path.resolve(__dirname, file)];
})
);
};
export default defineConfig({
// 開発サーバー設定
server: {
port: 5173,
strictPort: false,
cors: true,
},
// ビルド設定
build: {
rollupOptions: {
input: getHtmlEntries(),
},
},
// モジュール解決設定
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
},
});