Skip to content

Commit

Permalink
Merge pull request #126 from jpkleemans/update-example
Browse files Browse the repository at this point in the history
Update example to use Vite v5
  • Loading branch information
jpkleemans committed Nov 17, 2023
2 parents e61590d + 2318ac6 commit 4d7b672
Show file tree
Hide file tree
Showing 54 changed files with 1,339 additions and 3,910 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/e2e.yml
@@ -1,17 +1,16 @@
name: End-to-end tests
on: [push, pull_request]
on: [push]
jobs:
cypress-run:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Cypress run
uses: cypress-io/github-action@v4
uses: cypress-io/github-action@v6
with:
build: npm run example:build
start: npm run example:serve
wait-on: http://localhost:5000
start: npm run example:preview
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
5 changes: 2 additions & 3 deletions README.md
Expand Up @@ -92,10 +92,9 @@ import IconWithoutOptimizer from './my-icon.svg?skipsvgo'
```

### Use with TypeScript
If you use the loader in a Typescript project, you'll need to import your svg files with the `?component` param: `import MyIcon from './my-icon.svg?component'`.

You'll also need to reference the type definitions:
If you use the loader in a Typescript project, you'll need to reference the type definitions inside `vite-env.d.ts`:
```ts
/// <reference types="vite/client" />
/// <reference types="vite-svg-loader" />
```

Expand Down
5 changes: 4 additions & 1 deletion cypress.json
@@ -1,4 +1,7 @@
{
"baseUrl": "http://localhost:5000",
"baseUrl": "http://localhost:4173",
"pluginsFile": false,
"supportFile": false,
"screenshotOnRunFailure": false,
"video": false
}
5 changes: 0 additions & 5 deletions cypress/fixtures/example.json

This file was deleted.

2 changes: 1 addition & 1 deletion cypress/integration/spec.js
Expand Up @@ -42,7 +42,7 @@ describe('Vite SVG Loader', () => {
})

it('supports ?url param', () => {
cy.get('#url').contains(/^\/assets\/test\..+\.svg/)
cy.get('#url').contains(/^data:image\/svg\+xml/)
})

it('supports ?raw param', () => {
Expand Down
22 changes: 0 additions & 22 deletions cypress/plugins/index.js

This file was deleted.

25 changes: 0 additions & 25 deletions cypress/support/commands.js

This file was deleted.

20 changes: 0 additions & 20 deletions cypress/support/index.js

This file was deleted.

24 changes: 24 additions & 0 deletions example/.gitignore
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
3 changes: 3 additions & 0 deletions example/.vscode/extensions.json
@@ -0,0 +1,3 @@
{
"recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"]
}
18 changes: 18 additions & 0 deletions example/README.md
@@ -0,0 +1,18 @@
# Vue 3 + TypeScript + Vite

This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.

## Recommended IDE Setup

- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).

## Type Support For `.vue` Imports in TS

TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types.

If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:

1. Disable the built-in TypeScript Extension
1. Run `Extensions: Show Built-in Extensions` from VSCode's command palette
2. Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.
6 changes: 3 additions & 3 deletions examples/vue-ts/index.html → example/index.html
@@ -1,10 +1,10 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
<title>Vite + Vue + TS</title>
</head>
<body>
<div id="app"></div>
Expand Down

0 comments on commit 4d7b672

Please sign in to comment.