reactとvite で現在MPAの環境構築をしているものです。
やりたいこととしてはhtmlをentryポイントとして使用せずに、各ページのentryポイントとcssを各々build先を指定して
buildしたいです。
ただ.html、エントリポイントとして読む読むようになってるらしく、下記の設定だとerrorが出てしまいます。
ライブラリーモードを使用すると、html不要でbuildできるようですが、これは一つのファイルにまとめられてしまうので使用できそうにないので、、
viteでentryポイントでhtmlを使用せずに、任意のbuildすることは可能なのでしょうか?
//フロントエンド root/src ├ entries ├ Top/index.tsx ├ About/index.tsx ├ tailwind/index.css //バックエンド root/ ├ src/Top ├ index.twig ├ js/[build].js ├ src/About ├ index.twig ├ js/[build].js ├ styles/[build].css
vite.confi.js
import react from '@vitejs/plugin-react' import glob from 'glob' import path from 'path' import { defineConfig } from 'vite' const outputItems = [ { input: './entries/top/index.tsx', output: { file: './../src/Eccube/Resource/template/default/Top/js/index.js', format: 'cjs', }, }, ] // https://vitejs.dev/config/ export default defineConfig({ plugins: [react()], build: { rollupOptions: [outputItems[0]], assetsDir: '', }, resolve: { alias: [{ find: '@', replacement: '/src' }], }, })
error
Could not resolve entry module (index.html). error during build: Error: Could not resolve entry module (index.html).

0 コメント