forked from sveltejs/vite-plugin-svelte
-
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.
feat(vite-plugin-svelte): experimental option to use vite transforms …
…as svelte preprocessor (sveltejs#9) * wip: prototype implmenentation of a svelte style preprocessor using vites css transform * wip: cleanup code, ensure injectCss: false is passed, add option * wip: add typescript preprocessor to vite preprocess
- Loading branch information
Showing
16 changed files
with
354 additions
and
37 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,6 @@ | ||
.vscode | ||
.idea | ||
node_modules | ||
dist | ||
dist-ssr | ||
|
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,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" href="/favicon.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Svelte App</title> | ||
</head> | ||
<body> | ||
<script type="module" src="/src/index.js"></script> | ||
</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,17 @@ | ||
{ | ||
"name": "svite-preprocess-with-vite", | ||
"version": "0.0.0", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"serve": "vite preview" | ||
}, | ||
"devDependencies": { | ||
"@svitejs/vite-plugin-svelte": "workspace:*", | ||
"sass": "^1.32.8", | ||
"stylus": "^0.54.8", | ||
"svelte": "^3.35.0", | ||
"svelte-hmr": "^0.12.9", | ||
"vite": "^2.0.5" | ||
} | ||
} |
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,18 @@ | ||
<script lang="ts"> | ||
import Foo from './Foo.svelte' | ||
const world: string = 'world' // edit world and save to see hmr update | ||
</script> | ||
|
||
<h1 class="foo">Hello {world}</h1> | ||
<p>This is styled with scss using darken fn</p> | ||
<Foo /> | ||
|
||
<style lang="scss"> | ||
$blue: blue; | ||
p { | ||
color: darken($blue, 20); | ||
} | ||
h1.foo { | ||
color: $blue; /* change color an save to see hmr update */ | ||
} | ||
</style> |
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,15 @@ | ||
<script lang="ts"> | ||
let foo: string = 'stylus' | ||
export let bla: string = 'blub' | ||
</script> | ||
|
||
<h1>Styles with {foo} {bla}</h1> | ||
<p class="note">cool, huh?</p> | ||
|
||
<style lang="stylus"> | ||
/* prettier-ignore */ | ||
.note | ||
color #ff3e00 | ||
h1 | ||
color magenta | ||
</style> |
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,18 @@ | ||
const svelte = require('@svitejs/vite-plugin-svelte') | ||
const { defineConfig } = require('vite') | ||
|
||
module.exports = defineConfig(({ command, mode }) => { | ||
const isProduction = mode === 'production' | ||
return { | ||
plugins: [ | ||
svelte({ | ||
hot: !isProduction, | ||
emitCss: true, | ||
useVitePreprocess: true | ||
}) | ||
], | ||
build: { | ||
minify: isProduction | ||
} | ||
} | ||
}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,6 @@ body { | |
|
||
@media (min-width: 320px) { | ||
body { | ||
background-color: rebeccapurple; | ||
background-color: white; | ||
} | ||
} |
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
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
Oops, something went wrong.