refactor: configure vite and next.js for correct module loading
This commit is contained in:
		@@ -8,6 +8,6 @@
 | 
				
			|||||||
  </head>
 | 
					  </head>
 | 
				
			||||||
  <body>
 | 
					  <body>
 | 
				
			||||||
    <div id="root"></div>
 | 
					    <div id="root"></div>
 | 
				
			||||||
    <script type="module" src="/src/main.tsx"></script>
 | 
					    <script type="module" src="/src/main.tsx" defer></script>
 | 
				
			||||||
  </body>
 | 
					  </body>
 | 
				
			||||||
</html>
 | 
					</html>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,6 +2,7 @@ import { defineConfig } from "vite";
 | 
				
			|||||||
import react from "@vitejs/plugin-react";
 | 
					import react from "@vitejs/plugin-react";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default defineConfig({
 | 
					export default defineConfig({
 | 
				
			||||||
 | 
					  root: '.', // プロジェクトルートを明示
 | 
				
			||||||
  plugins: [react()],
 | 
					  plugins: [react()],
 | 
				
			||||||
  server: {
 | 
					  server: {
 | 
				
			||||||
    port: 3000,
 | 
					    port: 3000,
 | 
				
			||||||
@@ -12,5 +13,4 @@ export default defineConfig({
 | 
				
			|||||||
      input: "index.html",
 | 
					      input: "index.html",
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  root: process.cwd(), // 現在の作業ディレクトリ(frontend)をルートとして明示
 | 
					 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,6 +2,7 @@
 | 
				
			|||||||
const nextConfig = {
 | 
					const nextConfig = {
 | 
				
			||||||
  reactStrictMode: true,
 | 
					  reactStrictMode: true,
 | 
				
			||||||
  output: 'standalone',
 | 
					  output: 'standalone',
 | 
				
			||||||
 | 
					  // Vite を使用している場合は Next.js の dev server は使わない
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module.exports = nextConfig;
 | 
					module.exports = nextConfig;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user