Skip to content

When adding svelte plugin defineConfig.plugins throws unexpected token error.  #574

Closed
@Relaxe111

Description

@Relaxe111

Describe the bug

When i add in vite.config.ts :

//vite.config.ts
import { svelte, vitePreprocess } from '@sveltejs/vite-plugin-svelte';
import { defineConfig } from 'vite';

export default defineConfig({
  // Consult https://svelte.dev/docs#compile-time-svelte-preprocess
  // for more information about preprocessors
  //preprocess: vitePreprocess(),
  plugins: [
    svelte({
      preprocess: [vitePreprocess()],
    }),
  ],
});

i get following:

//in browser: 
[plugin:vite-plugin-svelte] /src/lib/Counter.svelte:2:11 Unexpected token
/src/lib/Counter.svelte:2:11
1 |  <script lang="ts">
 2 |    let count: number = 0
                 ^
 3 |    const increment = () => {
 4 |      count += 1

repro: https://stackblitz.com/edit/vitejs-vite-anfcqc?file=svelte.config.ts,package.json&terminal=dev

Reproduction URL

https://stackblitz.com/edit/vitejs-vite-anfcqc?file=svelte.config.ts,package.json&terminal=dev

Reproduction

No response

Logs

No response

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 7.17.0 - /usr/local/bin/npm
  npmPackages:
    @sveltejs/vite-plugin-svelte: ^2.0.2 => 2.0.2 
    svelte: ^3.55.0 => 3.55.1 
    vite: ^4.0.4 => 4.0.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions