feat(plugin-legacy): support file protocol #8524
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Sometimes I want the packaged web page to run locally without using services, such as
"file:///C:/demo/index.html"
.In chrome,
CORS
errors may occur when using local scripts for module scripts.So I need to use '@vitejs/plugin-legacy' to package it as a nomodule script.
At this time, I need to be able to inject and run nomodule scripts by distinguishing web protocol.
tr. 有时候我希望打包之后的网页能在本地运行,不使用服务,如"file:///C:/demo/index.html"。
在chrome由于module scripts使用本地脚本会出现跨域的错误。
所以我需要使用'@vitejs/plugin-legacy'将其打包为nomodule的脚本。
这时我需要能通过区分网页协议来注入和运行nomodule脚本。
fixes #12841
closes #2574
Additional context
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).