Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kukuqi666/tvbox-decrypt
基于vite的直播源格式转换 接口解密 工具
https://github.com/kukuqi666/tvbox-decrypt
vitejs vue
Last synced: 6 days ago
JSON representation
基于vite的直播源格式转换 接口解密 工具
- Host: GitHub
- URL: https://github.com/kukuqi666/tvbox-decrypt
- Owner: kukuqi666
- Created: 2024-11-06T03:57:10.000Z (13 days ago)
- Default Branch: main
- Last Pushed: 2024-11-06T04:27:02.000Z (12 days ago)
- Last Synced: 2024-11-06T05:20:21.052Z (12 days ago)
- Topics: vitejs, vue
- Language: Vue
- Homepage: https://kukuqi666.github.io/Tvbox-decrypt/
- Size: 1.87 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Scaffolding Your First Vite Project
Compatibility Note
Vite requires [Node.js](https://nodejs.org/en/) version 18+ or 20+. However, some templates require a higher Node.js version to work, please upgrade if your package manager warns about it.code-group
```bash [npm]
npm create vite@latest
``````bash [Yarn]
yarn create vite
``````bash [pnpm]
pnpm create vite
``````bash [Bun]
bun create vite
```Then follow the prompts!
You can also directly specify the project name and the template you want to use via additional command line options. For example, to scaffold a Vite + Vue project, run:
code-group
```bash [npm]
# npm 7+, extra double-dash is needed:
npm create vite@latest my-vue-app -- --template vue
``````bash [Yarn]
yarn create vite my-vue-app --template vue
``````bash [pnpm]
pnpm create vite my-vue-app --template vue
``````bash [Bun]
bun create vite my-vue-app --template vue
```See [create-vite](https://github.com/vitejs/vite/tree/main/packages/create-vite) for more details on each supported template: `vanilla`, `vanilla-ts`, `vue`, `vue-ts`, `react`, `react-ts`, `react-swc`, `react-swc-ts`, `preact`, `preact-ts`, `lit`, `lit-ts`, `svelte`, `svelte-ts`, `solid`, `solid-ts`, `qwik`, `qwik-ts`.
You can use `.` for the project name to scaffold in the current directory.
## Community Templates
create-vite is a tool to quickly start a project from a basic template for popular frameworks. Check out Awesome Vite for [community maintained templates](https://github.com/vitejs/awesome-vite#templates) that include other tools or target different frameworks.
For a template at `https://github.com/user/project`, you can try it out online using `https://github.stackblitz.com/user/project` (adding `.stackblitz` after `github` to the URL of the project).
You can also use a tool like [degit](https://github.com/Rich-Harris/degit) to scaffold your project with one of the templates. Assuming the project is on GitHub and uses `main` as the default branch, you can create a local copy using:
```bash
npx degit user/project#main my-project
cd my-projectnpm install
npm run dev
```## Manual Installation
In your project, you can install the `vite` CLI using:
code-group
```bash [npm]
npm install -D vite
``````bash [Yarn]
yarn add -D vite
``````bash [pnpm]
pnpm add -D vite
``````bash [Bun]
bun add -D vite
```And create an `index.html` file like this:
```html
Hello Vite!
```Then run the appropriate CLI command in your terminal:
code-group
```bash [npm]
npx vite
``````bash [Yarn]
yarn vite
``````bash [pnpm]
pnpm vite
``````bash [Bun]
bunx vite
```The `index.html` will be served on `http://localhost:5173`.
## `index.html` and Project Root
One thing you may have noticed is that in a Vite project, `index.html` is front-and-central instead of being tucked away inside `public`. This is intentional: during development Vite is a server, and `index.html` is the entry point to your application.
Vite treats `index.html` as source code and part of the module graph. It resolves `` that references your JavaScript source code. Even inline `<script type="module">` and CSS referenced via `<link href>` also enjoy Vite-specific features. In addition, URLs inside `index.html` are automatically rebased so there's no need for special `%PUBLIC_URL%` placeholders.
Similar to static http servers, Vite has the concept of a "root directory" which your files are served from. You will see it referenced as `<root>` throughout the rest of the docs. Absolute URLs in your source code will be resolved using the project root as base, so you can write code as if you are working with a normal static file server (except way more powerful!). Vite is also capable of handling dependencies that resolve to out-of-root file system locations, which makes it usable even in a monorepo-based setup.
Vite also supports [multi-page apps](./build#multi-page-app) with multiple `.html` entry points.
#### Specifying Alternative Root
Running `vite` starts the dev server using the current working directory as root. You can specify an alternative root with `vite serve some/sub/dir`.
Note that Vite will also resolve [its config file (i.e. `vite.config.js`)](/config/#configuring-vite) inside the project root, so you'll need to move it if the root is changed.## Command Line Interface
In a project where Vite is installed, you can use the `vite` binary in your npm scripts, or run it directly with `npx vite`. Here are the default npm scripts in a scaffolded Vite project:
<!-- prettier-ignore -->
```json [package.json]
{
"scripts": {
"dev": "vite", // start dev server, aliases: `vite dev`, `vite serve`
"build": "vite build", // build for production
"preview": "vite preview" // locally preview production build
}
}
```You can specify additional CLI options like `--port` or `--open`. For a full list of CLI options, run `npx vite --help` in your project.
Learn more about the [Command Line Interface](./cli.md)
## Using Unreleased Commits
If you can't wait for a new release to test the latest features, you will need to clone the [vite repo](https://github.com/vitejs/vite) to your local machine and then build and link it yourself ([pnpm](https://pnpm.io/) is required):
```bash
git clone https://github.com/vitejs/vite.git
cd vite
pnpm install
cd packages/vite
pnpm run build
pnpm link --global # use your preferred package manager for this step
```Then go to your Vite based project and run `pnpm link --global vite` (or the package manager that you used to link `vite` globally). Now restart the development server to ride on the bleeding edge
# Deploying a Static Site
The following guides are based on some shared assumptions:
- You are using the default build output location (`dist`). This location [can be changed using `build.outDir`](/config/build-options.md#build-outdir), and you can extrapolate instructions from these guides in that case.
- You are using npm. You can use equivalent commands to run the scripts if you are using Yarn or other package managers.
- Vite is installed as a local dev dependency in your project, and you have setup the following npm scripts:```json [package.json]
{
"scripts": {
"build": "vite build",
"preview": "vite preview"
}
}
```It is important to note that `vite preview` is intended for previewing the build locally and not meant as a production server.
::: tip NOTE
These guides provide instructions for performing a static deployment of your Vite site. Vite also supports Server Side Rendering. SSR refers to front-end frameworks that support running the same application in Node.js, pre-rendering it to HTML, and finally hydrating it on the client. Check out the [SSR Guide](./ssr) to learn about this feature. On the other hand, if you are looking for integration with traditional server-side frameworks, check out the [Backend Integration guide](./backend-integration) instead.
:::## Building the App
You may run `npm run build` command to build the app.
```bash
$ npm run build
```By default, the build output will be placed at `dist`. You may deploy this `dist` folder to any of your preferred platforms.
### Testing the App Locally
Once you've built the app, you may test it locally by running `npm run preview` command.
```bash
$ npm run preview
```The `vite preview` command will boot up a local static web server that serves the files from `dist` at `http://localhost:4173`. It's an easy way to check if the production build looks OK in your local environment.
You may configure the port of the server by passing the `--port` flag as an argument.
```json [package.json]
{
"scripts": {
"preview": "vite preview --port 8080"
}
}
```Now the `preview` command will launch the server at `http://localhost:8080`.
## GitHub Pages
1. Set the correct `base` in `vite.config.js`.
If you are deploying to `https://<USERNAME>.github.io/`, or to a custom domain through GitHub Pages (eg. `www.example.com`), set `base` to `'/'`. Alternatively, you can remove `base` from the configuration, as it defaults to `'/'`.
If you are deploying to `https://<USERNAME>.github.io/<REPO>/` (eg. your repository is at `https://github.com/<USERNAME>/<REPO>`), then set `base` to `'/<REPO>/'`.
2. Go to your GitHub Pages configuration in the repository settings page and choose the source of deployment as "GitHub Actions", this will lead you to create a workflow that builds and deploys your project, a sample workflow that installs dependencies and builds using npm is provided:
```yml
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pageson:
# Runs on pushes targeting the default branch
push:
branches: ['main']# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:# Sets the GITHUB_TOKEN permissions to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write# Allow one concurrent deployment
concurrency:
group: 'pages'
cancel-in-progress: truejobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload dist folder
path: './dist'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
```## GitLab Pages and GitLab CI
1. Set the correct `base` in `vite.config.js`.
If you are deploying to `https://<USERNAME or GROUP>.gitlab.io/`, you can omit `base` as it defaults to `'/'`.
If you are deploying to `https://<USERNAME or GROUP>.gitlab.io/<REPO>/`, for example your repository is at `https://gitlab.com/<USERNAME>/<REPO>`, then set `base` to `'/<REPO>/'`.
2. Create a file called `.gitlab-ci.yml` in the root of your project with the content below. This will build and deploy your site whenever you make changes to your content:
```yaml [.gitlab-ci.yml]
image: node:16.5.0
pages:
stage: deploy
cache:
key:
files:
- package-lock.json
prefix: npm
paths:
- node_modules/
script:
- npm install
- npm run build
- cp -a dist/. public/
artifacts:
paths:
- public
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
```## Netlify
### Netlify CLI
1. Install the [Netlify CLI](https://cli.netlify.com/).
2. Create a new site using `ntl init`.
3. Deploy using `ntl deploy`.```bash
# Install the Netlify CLI
$ npm install -g netlify-cli# Create a new site in Netlify
$ ntl init# Deploy to a unique preview URL
$ ntl deploy
```The Netlify CLI will share with you a preview URL to inspect. When you are ready to go into production, use the `prod` flag:
```bash
# Deploy the site into production
$ ntl deploy --prod
```### Netlify with Git
1. Push your code to a git repository (GitHub, GitLab, BitBucket, Azure DevOps).
2. [Import the project](https://app.netlify.com/start) to Netlify.
3. Choose the branch, output directory, and set up environment variables if applicable.
4. Click on **Deploy**.
5. Your Vite app is deployed!After your project has been imported and deployed, all subsequent pushes to branches other than the production branch along with pull requests will generate [Preview Deployments](https://docs.netlify.com/site-deploys/deploy-previews/), and all changes made to the Production Branch (commonly “main”) will result in a [Production Deployment](https://docs.netlify.com/site-deploys/overview/#definitions).
## Vercel
### Vercel CLI
1. Install the [Vercel CLI](https://vercel.com/cli) and run `vercel` to deploy.
2. Vercel will detect that you are using Vite and will enable the correct settings for your deployment.
3. Your application is deployed! (e.g. [vite-vue-template.vercel.app](https://vite-vue-template.vercel.app/))```bash
$ npm i -g vercel
$ vercel init vite
Vercel CLI
> Success! Initialized "vite" example in ~/your-folder.
- To deploy, `cd vite` and run `vercel`.
```### Vercel for Git
1. Push your code to your git repository (GitHub, GitLab, Bitbucket).
2. [Import your Vite project](https://vercel.com/new) into Vercel.
3. Vercel will detect that you are using Vite and will enable the correct settings for your deployment.
4. Your application is deployed! (e.g. [vite-vue-template.vercel.app](https://vite-vue-template.vercel.app/))After your project has been imported and deployed, all subsequent pushes to branches will generate [Preview Deployments](https://vercel.com/docs/concepts/deployments/environments#preview), and all changes made to the Production Branch (commonly “main”) will result in a [Production Deployment](https://vercel.com/docs/concepts/deployments/environments#production).
Learn more about Vercel’s [Git Integration](https://vercel.com/docs/concepts/git).
## Cloudflare Pages
### Cloudflare Pages via Wrangler
1. Install [Wrangler CLI](https://developers.cloudflare.com/workers/wrangler/get-started/).
2. Authenticate Wrangler with your Cloudflare account using `wrangler login`.
3. Run your build command.
4. Deploy using `npx wrangler pages deploy dist`.```bash
# Install Wrangler CLI
$ npm install -g wrangler# Login to Cloudflare account from CLI
$ wrangler login# Run your build command
$ npm run build# Create new deployment
$ npx wrangler pages deploy dist
```After your assets are uploaded, Wrangler will give you a preview URL to inspect your site. When you log into the Cloudflare Pages dashboard, you will see your new project.
### Cloudflare Pages with Git
1. Push your code to your git repository (GitHub, GitLab).
2. Log in to the Cloudflare dashboard and select your account in **Account Home** > **Pages**.
3. Select **Create a new Project** and the **Connect Git** option.
4. Select the git project you want to deploy and click **Begin setup**
5. Select the corresponding framework preset in the build setting depending on the Vite framework you have selected.
6. Then save and deploy!
7. Your application is deployed! (e.g `https://<PROJECTNAME>.pages.dev/`)After your project has been imported and deployed, all subsequent pushes to branches will generate [Preview Deployments](https://developers.cloudflare.com/pages/platform/preview-deployments/) unless specified not to in your [branch build controls](https://developers.cloudflare.com/pages/platform/branch-build-controls/). All changes to the Production Branch (commonly “main”) will result in a Production Deployment.
You can also add custom domains and handle custom build settings on Pages. Learn more about [Cloudflare Pages Git Integration](https://developers.cloudflare.com/pages/get-started/#manage-your-site).
## Google Firebase
1. Make sure you have [firebase-tools](https://www.npmjs.com/package/firebase-tools) installed.
2. Create `firebase.json` and `.firebaserc` at the root of your project with the following content:
```json [firebase.json]
{
"hosting": {
"public": "dist",
"ignore": [],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
``````js [.firebaserc]
{
"projects": {
"default": "<YOUR_FIREBASE_ID>"
}
}
```3. After running `npm run build`, deploy using the command `firebase deploy`.
## Surge
1. First install [surge](https://www.npmjs.com/package/surge), if you haven’t already.
2. Run `npm run build`.
3. Deploy to surge by typing `surge dist`.
You can also deploy to a [custom domain](http://surge.sh/help/adding-a-custom-domain) by adding `surge dist yourdomain.com`.
## Azure Static Web Apps
You can quickly deploy your Vite app with Microsoft Azure [Static Web Apps](https://aka.ms/staticwebapps) service. You need:
- An Azure account and a subscription key. You can create a [free Azure account here](https://azure.microsoft.com/free).
- Your app code pushed to [GitHub](https://github.com).
- The [SWA Extension](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azurestaticwebapps) in [Visual Studio Code](https://code.visualstudio.com).Install the extension in VS Code and navigate to your app root. Open the Static Web Apps extension, sign in to Azure, and click the '+' sign to create a new Static Web App. You will be prompted to designate which subscription key to use.
Follow the wizard started by the extension to give your app a name, choose a framework preset, and designate the app root (usually `/`) and built file location `/dist`. The wizard will run and will create a GitHub action in your repo in a `.github` folder.
The action will work to deploy your app (watch its progress in your repo's Actions tab) and, when successfully completed, you can view your app in the address provided in the extension's progress window by clicking the 'Browse Website' button that appears when the GitHub action has run.
## Render
You can deploy your Vite app as a Static Site on [Render](https://render.com/).
1. Create a [Render account](https://dashboard.render.com/register).
2. In the [Dashboard](https://dashboard.render.com/), click the **New** button and select **Static Site**.
3. Connect your GitHub/GitLab account or use a public repository.
4. Specify a project name and branch.
- **Build Command**: `npm install && npm run build`
- **Publish Directory**: `dist`5. Click **Create Static Site**.
Your app should be deployed at `https://<PROJECTNAME>.onrender.com/`.
By default, any new commit pushed to the specified branch will automatically trigger a new deployment. [Auto-Deploy](https://render.com/docs/deploys#toggling-auto-deploy-for-a-service) can be configured in the project settings.
You can also add a [custom domain](https://render.com/docs/custom-domains) to your project.
<!--
NOTE: The sections below are reserved for more deployment platforms not listed above.
Feel free to submit a PR that adds a new section with a link to your platform's
deployment guide, as long as it meets these criteria:1. Users should be able to deploy their site for free.
2. Free tier offerings should host the site indefinitely and are not time-bound.
Offering a limited number of computation resource or site counts in exchange is fine.
3. The linked guides should not contain any malicious content.The Vite team may change the criteria and audit the current list from time to time.
If a section is removed, we will ping the original PR authors before doing so.
-->## Flightcontrol
Deploy your static site using [Flightcontrol](https://www.flightcontrol.dev/?ref=docs-vite) by following these [instructions](https://www.flightcontrol.dev/docs/reference/examples/vite?ref=docs-vite).
## Kinsta Static Site Hosting
Deploy your static site using [Kinsta](https://kinsta.com/static-site-hosting/) by following these [instructions](https://kinsta.com/docs/react-vite-example/).
## xmit Static Site Hosting
Deploy your static site using [xmit](https://xmit.co) by following this [guide](https://xmit.dev/posts/vite-quickstart/).