KeJunMao / unplugin-preprocessor-directives

preprocessor directives for jsx,tsx,js,ts,html,css,vue and more
MIT License
61 stars 8 forks source link

conditions in html #12

Open spustlik opened 2 months ago

spustlik commented 2 months ago

I am trying to use this great plugin with vite. In typescript, it works well:

// #if DEV
console.log('DEV')
// #else
console.log('else DEV');
// #endif

but in html, with any combinations of whitespaces and # it doesn't work:

<!-- if DEV -->
    <div>DEV</div>
<!-- else -->
    <div>else DEV</div>
<!-- endif -->
<!-- #if DEV -->
    <div>#DEV</div>
<!-- #else -->
    <div>else #DEV</div>
<!-- #endif -->

It writes if and else branches. It seems like plugin is not active, but it works on typescript. I tried to write some code hacks to plugin, to log if my html file is proceeded. I tried to use "include" option, but nothing works. Please can you tell, what I am doing wrong? Thank you...

KeJunMao commented 2 months ago

try this?

https://github.com/KeJunMao/unplugin-preprocessor-directives/blob/main/test/fixtures/if.html