提交学习笔记专用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.6 KiB

  1. # vite-plugin-inspect
  2. [![NPM version](https://img.shields.io/npm/v/vite-plugin-inspect?color=a1b858&label=)](https://www.npmjs.com/package/vite-plugin-inspect)
  3. Inspect the intermediate state of Vite plugins. Useful for debugging and authoring plugins.
  4. <img width="1488" alt="Screenshot 2024-11-27 at 19 01 26" src="https://github.com/user-attachments/assets/ab6b86ac-d7ce-4424-a23f-02f265f547ea">
  5. ## Install
  6. ```bash
  7. npm i -D vite-plugin-inspect
  8. ```
  9. > [!NOTE]
  10. >
  11. > v10.x requires **Vite v6.0.1** or above.
  12. >
  13. > For Vite v2 to v5, use v0.8.x of `vite-plugin-inspect`. If you want to use it with both Vite 6 and below, you can still use v0.8.x, it's forwards compatible.
  14. Add plugin to your `vite.config.ts`:
  15. ```ts
  16. // vite.config.ts
  17. import Inspect from 'vite-plugin-inspect'
  18. export default {
  19. plugins: [
  20. Inspect()
  21. ],
  22. }
  23. ```
  24. Then run `npm run dev` and visit [localhost:5173/__inspect/](http://localhost:5173/__inspect/) to inspect the modules.
  25. ## Build Mode
  26. To inspect transformation in build mode, you can pass the `build: true` option:
  27. ```ts
  28. // vite.config.ts
  29. import Inspect from 'vite-plugin-inspect'
  30. export default {
  31. plugins: [
  32. Inspect({
  33. build: true,
  34. outputDir: '.vite-inspect'
  35. })
  36. ],
  37. }
  38. ```
  39. After running `vite build`, the inspector client will be generated under `.vite-inspect`, where you can use `npx serve .vite-inspect` to check the result.
  40. ## Sponsors
  41. <p align="center">
  42. <a href="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg">
  43. <img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg'/>
  44. </a>
  45. </p>
  46. ## License
  47. [MIT](./LICENSE) License &copy; 2021-PRESENT [Anthony Fu](https://github.com/antfu)