How to use npm installed package in laravel application?

 ̄綄美尐妖づ 提交于 2021-02-07 09:32:42

问题


I want to use select2 package in my laravel 5 application.

I installed it using npm install select2 and also ran npm run dev. It appears in my node_modules folder.

But how do I actually refer to the files - js and scss of select2 package in my app.blade.php ?


回答1:


Run npm run watch , because keeps track of all changes in .js.

In app.js add

require('select2/dist/js/select2');

In app.blade.php example:

<div>            
   <select class="js-select2 css-select2-50">
                    <option>1</option>
   </select>
</div>


来源:https://stackoverflow.com/questions/52402858/how-to-use-npm-installed-package-in-laravel-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!