EmailThis / extension-boilerplate

⚡️ A template for building cross browser extensions for Chrome, Opera & Firefox.
https://www.emailthis.me/open-source/extension-boilerplate
MIT License
3.28k stars 370 forks source link

How to target specific browser #3

Closed kivS closed 7 years ago

kivS commented 7 years ago

Hi there, nice project,

how to go about targeting single browser for apis not yet supported (like chrome's declarativeContent)?

also using yarn instead of npm provides better performance and reliability of deps

Thanks

bharani91 commented 7 years ago

Hi, that is an interesting question. You can try something like this -

// @if extension == 'chrome'
...use platform specific code...
// @endif

This uses the gulp-preprocess package for preprocessing HTML/JS files.

You could also write all the platform specific code in a separate file and import it only if the browser is Chrome (using a similar preprocessor conditional code).

Does this work for you?

I will switch to yarn shortly.

kivS commented 7 years ago

yep that solves it, thanks!