emosheeep / vite-plugin-virtual-mpa

Out-of-box MPA plugin for Vite, generate multiple entries using only one template.
https://stackblitz.com/~/github.com/emosheeep/vite-plugin-virtual-mpa
MIT License
109 stars 15 forks source link

Ejs template doesn't work properly #70

Open Junior2Ran opened 2 months ago

Junior2Ran commented 2 months ago

My ejs template doesn't work, it might goes wrong somewhere. It shows error when vite dev, the injectedScript in builded index.html turns to be a js virtual file.

image image

Please help ! How can I solve the problem ? I have tried:

  1. add base config, not work.
  2. delete type=module in injectedScript, vite shows error that import.meta.env must in module.
  3. try to turn the virtual file to a simple js code segment, but I don't know how to do

The template is like below

image

And my plugin config is like

image
emosheeep commented 2 months ago

Could you please try to write scripts in index.html like?

<script src="<%= injectScript %>">

Junior2Ran commented 2 months ago

It works on index.html. But it doesn't work on app.html. Only index.html needs injecting script. Is there a way to convert the inject content to be inline string?

emosheeep commented 2 months ago

<%= if(xxx){xxx} %> You can reference the ejs docs