Where should I store JS in Laravel 5?

▼魔方 西西 提交于 2019-12-22 04:25:09

问题


There are 2 places where I can store javascripts: resources/assets/javascripts and public/js.

If we put the files in resources/assets/javascripts, we should add gulp tasks to copy them. And this is a weakness of this method. And we will need path mapping in browser debugger.

If we put these files in public/js, we will have our source JS and compiled JS in one place and they will be messed up.

So, where should I store JS in Laravel 5?


回答1:


The "Laravel-5" answer is to put them in resources/assets/javascripts. Then you use Laravel-Elixer, which is the new npm package from Taylor + Jeffrey Way that handles the entire asset management for you using gulp.

Using Laravel-Elixer, you can publish, combine, minifiy and version control all your css + js assets in a simple workflow.

Elixer does alot more - you can read about it here: https://github.com/laravel/elixir

Jeffrey Way has also done a whole Laracast series on it (which I think this series is free): https://laracasts.com/index/elixir




回答2:


Found my old question and decided to answer myself.

In 2018 it's better to split the system into many separate projects: backend, frontend, iOS app, Android app, etc.
And each app may have its own build system, directory structure, etc.



来源:https://stackoverflow.com/questions/27765551/where-should-i-store-js-in-laravel-5

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