-
-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support .svg in svelte extensions (#78)
* feat: svg import * add changeset * chore: rename asset-import to custom-extensions * fix(custom-extensions): update vite config * chore(custom-extensions): rename spec file * fix(custom-extensions): add pnpm preview * more generic prevention of asset plugin interference for custom extensions Co-authored-by: dominikg <dominik.goepel@gmx.de>
- Loading branch information
Showing
11 changed files
with
150 additions
and
25 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,5 @@ | ||
--- | ||
'@sveltejs/vite-plugin-svelte': minor | ||
--- | ||
|
||
Support svg extension |
5 changes: 5 additions & 0 deletions
5
packages/e2e-tests/custom-extensions/__tests__/custom-extensions.spec.ts
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,5 @@ | ||
import { getText } from '../../testUtils'; | ||
|
||
test('should render svg', async () => { | ||
expect(await getText('#test-svg')).toBe('Foo bar=bar'); | ||
}); |
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 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width,initial-scale=1" /> | ||
|
||
<title>Svelte app</title> | ||
|
||
<script type="module" src="/src/main.js"></script> | ||
</head> | ||
|
||
<body></body> | ||
</html> |
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 @@ | ||
{ | ||
"name": "e2e-tests-custom-extensions", | ||
"private": true, | ||
"version": "1.0.0", | ||
"scripts": { | ||
"build": "vite build", | ||
"dev": "vite", | ||
"preview": "vite preview" | ||
}, | ||
"devDependencies": { | ||
"@sveltejs/vite-plugin-svelte": "workspace:*", | ||
"svelte": "^3.38.3", | ||
"svelte-hmr": "^0.14.4", | ||
"vite": "^2.3.8" | ||
} | ||
} |
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,26 @@ | ||
<script> | ||
import TestSvg from './components/TestSvg.svg'; | ||
</script> | ||
|
||
<main> | ||
<p> | ||
Visit the <a href="https://svelte.dev/tutorial">Svelte tutorial</a> to learn how to build Svelte | ||
apps. | ||
</p> | ||
<TestSvg /> | ||
</main> | ||
|
||
<style> | ||
main { | ||
text-align: center; | ||
padding: 1em; | ||
max-width: 240px; | ||
margin: 0 auto; | ||
} | ||
@media (min-width: 640px) { | ||
main { | ||
max-width: none; | ||
} | ||
} | ||
</style> |
11 changes: 11 additions & 0 deletions
11
packages/e2e-tests/custom-extensions/src/components/TestSvg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,7 @@ | ||
import App from './App.svelte'; | ||
|
||
const app = new App({ | ||
target: document.body | ||
}); | ||
|
||
export default app; |
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,21 @@ | ||
const { svelte } = require('@sveltejs/vite-plugin-svelte'); | ||
const { defineConfig } = require('vite'); | ||
|
||
module.exports = defineConfig(() => { | ||
return { | ||
plugins: [svelte({ extensions: ['.svelte', '.svg'] })], | ||
build: { | ||
// make build faster by skipping transforms and minification | ||
target: 'esnext', | ||
minify: false | ||
}, | ||
server: { | ||
watch: { | ||
// During tests we edit the files too fast and sometimes chokidar | ||
// misses change events, so enforce polling for consistency | ||
usePolling: true, | ||
interval: 100 | ||
} | ||
} | ||
}; | ||
}); |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.