我应该在哪里存储 Laravel 5 中的 JS?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27765551/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 10:38:33  来源:igfitidea点击:

Where should I store JS in Laravel 5?

javascriptlaravelassetsgulplaravel-5

提问by Dmitry

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

有 2 个地方可以存储 javascript:resources/assets/javascriptspublic/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.

如果我们将文件放入 中resources/assets/javascripts,我们应该添加 gulp 任务来复制它们。这是这种方法的一个弱点。我们将需要浏览器调试器中的路径映射。

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.

如果我们把这些文件放在public/js.

So, where should I store JS in Laravel 5?

那么,在 Laravel 5 中我应该在哪里存储 JS?

采纳答案by Dmitry

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.

2018年最好把系统拆分成很多独立的项目:后端、前端、iOS app、Android app等,
而且每个app可能有自己的构建系统、目录结构等。

回答by Laurence

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

“Laravel-5”的答案是将它们放入resources/assets/javascripts. 然后你使用 Laravel-Elixer,这是npmTaylor + Jeffrey Way的新包,它使用 gulp为你处理整个资产管理。

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

使用 Laravel-Elixer,您可以在一个简单的工作流程中发布、合并、缩小和版本控制所有 css + js 资产。

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

Elixer 做得更多 - 你可以在这里阅读它: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

Jeffrey Way 还做了一个完整的 Laracast 系列(我认为这个系列是免费的):https://laracasts.com/index/elixir