Skip to content

comments

  • Type: boolean | object with the properties below
  • Optional

Control which comments are preserved in the output.

  • true: Preserve legal, annotation, and JSDoc comments (default)
  • false: Strip all comments
  • Object: Granular control over comment categories

Note: Regular line and block comments without these markers are always removed regardless of this option.

When both legalComments and comments.legal are set, comments.legal takes priority.

WARNING

Some comments may be still removed due to some known bugs: #7257, #7387

Default

ts
true

annotation?

  • Type: boolean
  • Optional

Comments that contain @__PURE__, @__NO_SIDE_EFFECTS__ or @vite-ignore

jsdoc?

  • Type: boolean
  • Optional

JSDoc comments

  • Type: boolean
  • Optional

Comments that contain @license, @preserve or start with //! or /*!