Baw-Appie / vite-plugin-vue-pug-indent-fix

https://www.npmjs.com/package/vite-plugin-vue-pug-indent-fix
4 stars 2 forks source link

This isn't work in Vite. #1

Open Rick02022 opened 1 year ago

Rick02022 commented 1 year ago

This is my vite.config, but it isn't work. It still have error 'unexpected token "indent"' at run build. I use Vite v4.0.0. What part have I done wrong?

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vuePugPlugin from 'vue-pug-plugin'
import eslintPlugin from 'vite-plugin-eslint'
import vitePluginVuePugIndentFix from 'vite-plugin-vue-pug-indent-fix'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vitePluginVuePugIndentFix(),
    vue({
      template: {
        // 'preprocessOptions' is passed through to the pug compiler
        preprocessOptions: {
          plugins: [vuePugPlugin],
        },
      },
    }),
    eslintPlugin(),
  ],
})
Baw-Appie commented 1 year ago

You don't need to installing additional package for use pug.

Check this project:
https://stackblitz.com/edit/vitejs-vite-iqkgpj?file=src/App.vue

Rick02022 commented 1 year ago

I try to run that project, but its building production is wrong. Is that normal?

jmuxfeldt commented 11 months ago

I had the same issue only for production. It happens when a Vue file doesn't begin with "<template", e.g. you have the script block first, or even if there is an empty line first. You can exchange "startsWith" with "includes" in the plugin source, and all will work as desired.