samonxian / vite-plugin-build

Vite library mode plugin,which support transfom the whole folder and emit dceclaration files. Vite 库模式插件,支持整个文件夹的转换和声明文件生成。(支持 vanilla、react、vue3 和 svelte)
60 stars 6 forks source link

watch mode doesn't work #3

Closed sebas0811buitrago closed 1 year ago

sebas0811buitrago commented 2 years ago

if I run npx vite build --watch it just build one time and doesn't wait for changes to recompile again, but without the plugin it works well.

samonxian commented 2 years ago

It is not support cli watch mode, you can use vite config file to use watch mode and but watch mode is not support for emitting typescript declaration file.

The watch mode setting is the same as vite watch mode.

export default defineConfig({
  plugins: [
    buildPlugin({
      fileBuild: {
        emitDeclaration: true,
        watch: {},
      },
    }),
  ],
});
maksimaliabyshev commented 2 years ago

@sebas0811buitrago You can use a crutch in vite.config.js

const watch = process.argv.join().includes('--watch')
  ? {
      include: ['src/**'],
    }
  : null;

console.log(watch);

export default defineConfig({
  plugins: [
    buildPlugin({
      fileBuild: {
        emitDeclaration: true,
        watch
      },
    }),
  ],
});