Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plugin-legacy): support file protocol #8524

Merged
merged 4 commits into from
Apr 25, 2023

Conversation

wmz46
Copy link
Contributor

@wmz46 wmz46 commented Jun 10, 2022

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?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@sapphi-red sapphi-red added plugin: legacy p2-nice-to-have Not breaking anything but nice to have (priority) labels Apr 22, 2023
sapphi-red
sapphi-red previously approved these changes Apr 22, 2023
Copy link
Member

@sapphi-red sapphi-red left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to have this. This is more simple than #2574. This adds a little code size for uses that doesn't worry about file protocol. But I think it's ok as the size is very small.

@bluwy bluwy changed the title feat: plugin-legacy support protocal file (tr. plugin-legacy支持file协议) feat(plugin-legacy): support file protocol Apr 24, 2023
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
@patak-dev patak-dev merged commit 7a87ff4 into vitejs:main Apr 25, 2023
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-nice-to-have Not breaking anything but nice to have (priority) plugin: legacy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

【@vitejs/plugin-legacy】type="module" 对于file协议引入资源会有跨域问题
4 participants