-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8249ff7
Showing
18 changed files
with
5,118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
env: | ||
TERM: xterm-256color | ||
FORCE_COLOR: 1 | ||
|
||
jobs: | ||
pull-request: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Use Corepack | ||
run: | | ||
set -e | ||
corepack enable | ||
- name: Use Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Restore | ||
run: | | ||
set -e | ||
pnpm install --frozen-lockfile | ||
- name: Build | ||
run: | | ||
set -e | ||
pnpm build | ||
- name: Test | ||
run: | | ||
set -e | ||
pnpm test | ||
# - name: Publish (dry-run) | ||
# run: | | ||
# set -e | ||
# pnpm -r publish --no-git-checks --dry-run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
concurrency: | ||
group: ${{ github.workflow }} | ||
|
||
env: | ||
TERM: xterm-256color | ||
FORCE_COLOR: 1 | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Use Corepack | ||
run: | | ||
set -e | ||
corepack enable | ||
- name: Use Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Restore | ||
run: | | ||
set -e | ||
pnpm install --frozen-lockfile | ||
- name: Build | ||
run: | | ||
set -e | ||
pnpm build | ||
- name: Test | ||
run: | | ||
set -e | ||
pnpm test | ||
# - name: Publish | ||
# run: | | ||
# set -e | ||
# pnpm config --location=project set //registry.npmjs.org/:_authToken '${NPM_TOKEN}' | ||
# pnpm -r publish --no-git-checks | ||
# env: | ||
# NPM_TOKEN: ${{secrets.NPM_TOKEN}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.vscode/ | ||
.terraform/ | ||
node_modules/ | ||
lib/ | ||
dist/ | ||
out/ | ||
coverage/ | ||
|
||
.DS_Store | ||
.env* | ||
*.tar | ||
*.gz | ||
*.tgz | ||
*.zip | ||
*.log | ||
aws.ini |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
reporter=append-only |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Copyright 2024 Chris Ackerman | ||
|
||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
|
||
THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Vite Live Preview | ||
|
||
Start preview server which updates on file changes. | ||
|
||
## Usage | ||
|
||
Install the package in your project. | ||
|
||
```sh | ||
npm install --save-dev vite-live-preview | ||
``` | ||
|
||
Add a `start` script to your `package.json` file. | ||
|
||
```json | ||
{ | ||
"scripts": { | ||
"preview": "vite-live-preview" | ||
} | ||
} | ||
``` | ||
|
||
Start the live preview. | ||
|
||
```sh | ||
npm start | ||
``` | ||
|
||
The command can be run with `npx` if you prefer not to add it as a dependency. | ||
|
||
```sh | ||
npx vite-live-preview | ||
``` | ||
|
||
## Options | ||
|
||
All Vite [preview command options](https://vitejs.dev/guide/cli#vite-preview) are supported, in addition to the following options. | ||
|
||
### `--reload [boolean]` | ||
|
||
Allow or disable automatic browser reloading on rebuild. The default is true. | ||
|
||
Use `--reload false` to disable automatic reloading. Manually reloading the page after a rebuild will still show the updated content. | ||
|
||
## The Problem | ||
|
||
There are cases where the Vite dev server is not adequate. It does not bundle the project, and it relies on the browser to load ES modules directly. This can be slow (especially with "barrel" files), and does not accurately represent the final build. | ||
|
||
The Vite `preview` command is a good alternative, but it does not do an initial build or automatically rebuild on file changes. | ||
|
||
This tool is roughly equivalent to running `vite build --watch & vite preview` to start a build (with file watching), and a preview server, in parallel. Additionally, it will also automatically trigger browser reloads after the watcher triggers a rebuild. | ||
|
||
### Related Github Issues | ||
|
||
- [Vite Preview Watch Mode #5196](https://github.com/vitejs/vite/issues/5196) | ||
- [Consider treeshaking module for serving files in dev mode #8237](https://github.com/vitejs/vite/issues/8237) | ||
- [vite preview can't use --mode option #17410](https://github.com/vitejs/vite/issues/17410) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env node | ||
// eslint-disable-next-line import/no-unresolved | ||
import './dist/index.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { defaultRelaxedFiles, rational } from 'eslint-config-rational'; | ||
|
||
export default rational({ | ||
enableJsdoc: false, | ||
relaxedFiles: [...defaultRelaxedFiles, '**/*.js'], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
"name": "vite-live-preview", | ||
"version": "0.1.0", | ||
"description": "Start a Vite build (with watching) and preview server.", | ||
"license": "ISC", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://Shakeskeyboarde/vite-live-preview.git" | ||
}, | ||
"keywords": [ | ||
"vite", | ||
"live", | ||
"preview", | ||
"dev", | ||
"watch", | ||
"server" | ||
], | ||
"scripts": { | ||
"build": "vite build", | ||
"eslint": "eslint .", | ||
"depcheck": "depcheck --ignores=typescript", | ||
"test": "pnpm eslint && pnpm depcheck", | ||
"global-install": "pnpm i -g \"$PWD\"" | ||
}, | ||
"files": [ | ||
"dist", | ||
"bin.js" | ||
], | ||
"bin": { | ||
"vite-live-preview": "bin.js", | ||
"vlp": "bin.js" | ||
}, | ||
"type": "module", | ||
"packageManager": "[email protected]+sha256.e1f9e8d1a16607a46dd3c158b5f7a7dc7945501d1c6222d454d63d033d1d918f", | ||
"devDependencies": { | ||
"@types/node": "^20.14.2", | ||
"depcheck": "^1.4.7", | ||
"eslint": "^8", | ||
"eslint-config-rational": "^5.0.15", | ||
"typescript": "^5.4.5", | ||
"vite-plugin-checker": "^0.6.4", | ||
"vite-plugin-config-lib": "^0.2.0", | ||
"vite-plugin-data": "^0.2.5" | ||
}, | ||
"dependencies": { | ||
"@commander-js/extra-typings": "^12.1.0", | ||
"@types/ansi-html": "^0.0.0", | ||
"@types/ws": "^8.5.10", | ||
"ansi-html": "^0.0.9", | ||
"chalk": "^5.3.0", | ||
"commander": "^12.1.0", | ||
"escape-goat": "^4.0.0", | ||
"ws": "^8.17.0" | ||
}, | ||
"peerDependencies": { | ||
"vite": ">=5.2.13" | ||
} | ||
} |
Oops, something went wrong.