Watchesforfilechangesinyourextension'sdirectory.Whenachangeisdetected,itreloadstheextensionandrefreshestheactivetab(tore-triggertheupdatedscripts).
Here'sablogpostexplainingit(thankstoKingOfNothingforthetranslation).
FeaturesWorksbycheckingtimestampsoffilesSupportsnesteddirectoriesAutomaticallydisablesitselfinproductionAndit'sundera40linesofcode!HowToUseDrophot-reload.jstoyourextension'sdirectory.
Putthefollowingintoyourmanifest.jsonfile:
"background":{"scripts":["hot-reload.js"]}Also,youcansimplyclonethisrepositoryanduseitasaboilerplateforyourextension.
InstallingFromNPMItisalsoavailableasNPMmodule:
npminstallcrx-hotreloadThenusearequire(orimport)toexecutethescript.
LimitationsDoesnotworkwithManifestVersion3,asChromehasrecentlyremovedtheAPIsessentialforworkingwithfilesystemfrombackgroundscripts:https://stackoverflow.com/questions/65975659/how-do-i-get-access-to-all-the-files-in-the-extension-in-chrome-extension-manife/65976345:(
评论