Closed dncore closed 2 years ago
This warning is output by vite.
You can check the code.
This warning is output by vite.
You can check the code.
- Are the environment variables read correctly?
- Are the prefix and suffix configured properly?
yes, all the environment variables got readed and prefix/suffix configured, but it only works properly when local serving
Can you provide a code snippet?
Can you provide a code snippet?
Just use the env variables as the Usage example in this repo,
the only difference is,
insert <script src="<{ VITE_APP_HOST }>***.js"></script>
to html file, rather than <script src="//<{ VITE_APP_HOST }>***.js"></script>
write variables in .env.xxx file,
VITE_APP_HOST
should be'/'
when dev serving and'https://www.my-site.com/resource/'
when prod bundling.
as far as I think, this issue is caused by the conflict between my dev requirement and vite's template bundling strategy, but not the plugin. Anyway, thanks for your reply.
inject an Env variable as a part of scripts tag path In the index.html file
<script src="<{ VITE_APP_DEMO_URL }>my/path/demo.js"></script>
it only works for dev mode, when building, warns with info:<script src="<{ VITE_APP_DEMO_URL }>my/path/demo.js"> in "/index.html" can't be bundled without type="module" attribute
after bundling, nothing changed with the script path for theindex.html
in dist folder, still<{ VITE_APP_DEMO_URL }>
. it seems like the rollup bundler recognize the path as a file to bundle.