Replies: 7 comments 6 replies
-
|
Emm... Vite build the page via |
Beta Was this translation helpful? Give feedback.
-
|
I also need to locally run index.html from dist folder. is there any way? EDIT: found this library here but I prefer not to use lib |
Beta Was this translation helpful? Give feedback.
-
|
I've made a very small vite plugin to build the project and directly use the built |
Beta Was this translation helpful? Give feedback.
-
|
Use this: |
Beta Was this translation helpful? Give feedback.
-
|
You can create custom plugin to remove crossorigin attribute. This will allow to use http requests in site served by file:// and then |
Beta Was this translation helpful? Give feedback.
-
|
any update please? there are no way to run in file protocol. I am stuck at vue CLI now |
Beta Was this translation helpful? Give feedback.
-
|
@JuanQP Thanks so much for the plugin! I just got it working in the new version of Vite released last week, Vite 8. It didn't require any changes to the plugin, which is great news! I copied the plugin code and used it locally, with two minor changes (renaming import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
export function makeOffline() {
return {
name: 'iife',
apply: 'build',
enforce: 'post',
transformIndexHtml(html) {
return html.replace(' type="module" crossorigin ', ' defer ');
},
};
}
export default defineConfig({
plugins: [react(), makeOffline()],
base: "./",
define: { 'import.meta': {} },
build: {
rolldownOptions: {
output: {
format: "iife"
}
}
...
}
});Caveat: It seems the IIFE format can be pretty picky about imports. Before using this plugin, I was using Material UI 5 with Vite 7. I upgraded to Vite 8, which necessitated turning on the I upgraded to Material UI 6, which fixed the issue and now I can generate IIFE format and open the app in my web browser without using a server. Note: It works fine whether I have If you're having these sorts of issues, don't give up hope! I would try upgrading the third-party library you use, or using a different format or version. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Because we are mixed development, embedded h5 page, open using file protocol, and vite must be http protocol to request, how to solve this
Beta Was this translation helpful? Give feedback.
All reactions