Reputation: 62
First case: i've got some script, which i've writed by myself(lets call it requests.js).
Second case: there is a big plugin TinyMCE, which i can install from bower or npm.
In first case as far as i understand, i should save my scripts in resources/assets/js. But where should i call them after this? There are 2 files in assets/js, which were installed with Laravel 5.3: app.js and bootstrap.js. Should i call my scripts in these files and then gulp them into a single one?
In second case i should use some npm or bower package manager. But, what should i do next? Where should i call this installed packages?In assets/js/ - app.js or bootstrap.js? But how, or maybe i shouldn't do it?
Upvotes: 0
Views: 655
Reputation: 3710
It's hard to put bower components in resource/assets/js only, because these components often consist of many files, js/css/others. I just use bower install inside root of the installation, bower_components dir appears and I put it into .gitignore. Anyone who pulls changes, can do bower install.
Going further, I make file, where I create json object with two values, js and css, where I put path to files I need. Then I require it inside gulp.js and I can do whatever I want with these files. Usually concat, minify, copy result to public.
Theres nothing wrong with putting frontend into same server. Maybe you work alone or in the small team, and you don't have time to manage too many things. Common practice I see all around is that people make dir angular inside root and just grab all js/html files inside this dir, and copy them to public inside gulp.
Upvotes: 1
Reputation: 13630
You should install your bower components in your resources/assets/js
folder. Then add any of these components to your build process in your gulpfile. This way, you have total control over what gets concatenated and minified and ultimately included in your templates.
Upvotes: 1
Reputation: 5796
It's opinion based, but I think it is not a good practice to mix front-end and back-end.
Your public (front-end) files, like bootstrap, you should store them in public/
of the Laravel installation. You can use public/assets/js
, etc. The folder resources
is not available in your html files (if you mean the folder of your Laravel installation).
A better approach is to separate totally
your front-end from back-end. In that case, you need a front-end framework, like AngularJS or Ember.
Why?
replace
one of them without troubles
in the otherthird party api
(https://api.yourdomein.com/v1/...)No conflicts
with blade views and other template formatsseparation of responsibilities
Upvotes: 1