packages/svelte-comment-injector/README.md
A Svelte preprocessor that injects an HTML comment at the top of every component, making it easier to identify components in browser DevTools.
<!-- Begin MyComponent.svelte -->
<div class="my-component">
<!-- Component content -->
</div>
<!-- End MyComponent.svelte -->
npm install @gitbutler/svelte-comment-injector --save-dev
Add the preprocessor to your Svelte configuration:
// svelte.config.js
import svelteInjectComment from "@gitbutler/svelte-comment-injector";
export default {
preprocess: [svelteInjectComment()],
// ...rest of your config
};
You can customize the comment format by passing options to the preprocessor:
// svelte.config.js
import svelteInjectComment from "@gitbutler/svelte-comment-injector";
export default {
preprocess: [
svelteInjectComment({
enabled: true, // Enable or disable the comment injection
showEndComment: true, // Show the end comment
showFullPath: false, // Show the full path in the comment
}),
],
// ...rest of your config
};