Skip to content

not working with svelte-kit. #9

@ohbob

Description

@ohbob

terminal

mkdir combo3
cd combo3
npm init svelte@next
pnpx svelte-add scss
pnpx svelte-add tailwindcss
npm install -D svimg
npm install

svelte.config.js

import preprocess from 'svelte-preprocess';
import imagePreprocessor from 'svimg';

/** @type {import('@sveltejs/kit').Config} */
const config = {
    preprocess: [
        imagePreprocessor({
            inputDir: "static",
            outputDir: "static/g",
            webp: true,
            avif: true,
        }),
        preprocess({
            "postcss": true
        }),
    ],
    kit: {
        // hydrate the <div id="svelte"> element in src/app.html
        target: '#svelte',
    }
};

export default config;
// Workaround until SvelteKit uses Vite 2.3.8 (and it's confirmed to fix the Tailwind JIT problem)
const mode = process.env.NODE_ENV;
const dev = mode === "development";
process.env.TAILWIND_MODE = dev ? "watch" : "build";

index.svelte

<script lang="ts">
  const hello: string = 'world';
  import Image from 'svimg'
</script>

<style lang="scss">
  section{
    @apply bg-red-50 p-3;
    p{
      @apply text-[brown] bg-blue-50 p-2 rounded;
    }
  }
</style>

<section>
  <p>hey yay</p>
</section>

<Image src="girls.jpg" />

<section>
  <p>yay hey {hello}</p>
</section>

image

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions