Hey everyone,
I’m hoping someone can point me in the right direction on how I would go about including a 3rd party npm library into a custom component. Using the daterangerpicker library for example:
1 - npm i daterangepicker ← Installs fine
2 - I am including it in my plugin/components/FilterTransactions.php as so:
public function onRun(){
$this->filterTransactions();
$this->addJs(‘/node_modules/daterangepicker/moment.min.js’);
$this->addJs(‘/node_modules/daterangepicker/daterangepicker.js’);
$this->addCss(‘/node_modules/daterangepicker/daterangepicker.css’);
$this->addJs(‘/plugins/ryansandnes/complex/components/filtertransactions/assets/js/filtertransactions.js’);
}
Is this accurate to include it in this way, or is there somewhere else I should be doing a @import? Usually these libraries don’t require me to include separate libraries on top of them. In this case I needed to include daterangepicker/moment.min.js as well so I just want to make sure I’m not about to develop a terrible habbit!
Thanks!