问题标签 [laravel-mix]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
27461 浏览

node.js - Combining Multiple Files with Laravel Mix

I am currently in the process of diving into Laravel Mix and so far, whilst I fully understand what Laravel Mix is and how it works, I am trying to understand a little more about the common practices and 'How-Tos'...

For instance, consider this file structure:

Now, ideally, I would like the following combined and minified in the following way:

As far as I understand, the way to achieve this is something like the following:

My Question

Quite simply, I would like to know if the above is the correct method for doing what I am trying to do? Are there better ways, or more common ways of achieving this?

If the above structure is wrong and there are other ways my files should be combined then please share your knowledge. However, unless there is a very good reason, I would like to avoid the following:

  • Serving two separate files for each page i.e. app.min.js and index.min.js. This requires two lookups per page, ideally it should be as few as possible
  • Serving the same file to ALL pages on my site. Serving code to a page that is not going to use it is a waste of resource, regardless of caching...

One Idea...

I noticed a line of code in one of the JS files; require('./bootstrap');. Call me old fashioned but I have never seen this in JavaScript (I assume it is from node.js). That said, obviously it is just loading the bootstrap.js file as a dependency into the specific file. So, with this in mind, would the following solution be better:

about.js

webpack.mix.js:

If this is a better solution then how do I include files using SASS as well? Are there ways the above can be improved at all?

0 投票
0 回答
307 浏览

laravel - 使用 Laravel Mix 进行日志记录?

使用 elixir,我曾经能够通过以下方式登录:

我怎样才能通过混合达到同样的效果?我试过 mix.log 没有运气。

0 投票
2 回答
469 浏览

laravel - 在 laravel-mix 中替代 elixir `mix.scriptsIn`

Laravel 5.4 引入了 laravel-mix。
使用 elixir,我有一项任务将所有供应商文件加载到一个特定的文件中:

可以用 laravel-mix 做同样的事情吗?

使用mix.js('/path/to/folder', 'public/js/vendor.js')我得到一个错误:

0 投票
1 回答
1358 浏览

laravel - laravel mix 构建成功,但 vue.js 新组件不起作用或没有出现任何更改

我第一次在我的 laravel 应用程序中使用 vue.js。每次出现 laravel mix 构建成功但我的 vie.js 评论更改未显示的消息。

我忘记运行任何重要的命令?

看法:

零件

0 投票
1 回答
1010 浏览

php - laravel mix 不导入所有文件。升级到 laravel 5.4

我想将 laravel 5,3 升级到 5.4,但是当我更新 laravel mix 时,我遇到了这样的错误。在我的 webpack.mix.js 中,我包含了这些文件:

运行 npm run dev 后,它给出:

以前我使用 elixer... 在我的 package.json 我有:

我尝试了 laravel mix 的所有方法来解决这个问题,也看到了这个的参考,但我无法得到任何解决方案,是否可以使用 elixer。我有: Laravel Mix 版本:0.8.1 节点版本(node -v):6.9.1 NPM 版本(npm -v):4.2 操作系统:ubuntu 16.4 lts

0 投票
1 回答
412 浏览

node.js - laravel webmix 运行出错

0 投票
1 回答
122 浏览

javascript - 使用 webpack 为浏览器打包一个节点应用程序

所以这可能很幼稚,但我可以在浏览器中运行仅节点样式的应用程序吗?我已经看到了前端的东西。我见过后端的东西。我想在浏览器中运行https://github.com/lapwinglabs/x-ray并做一些快速而肮脏的事情(这段代码可能并不完美)

尽管没有 iframe,但要完成整个站点。目的是让我可以以某种全球方式在公司内部资产上重新编写 CSS。我将能够只传递一个 url 并显示页面。如果我有自定义 css,那么它将处于活动状态。我仍然需要进行身份验证,但此时此刻我并不担心。

我过去曾使用过 x 射线和 express,它的作用就像一个魅力。在这种情况下,尽管我喜欢 Laravel 并希望在其中支持我的应用程序。

最新的 Laravel 有“mix”,一个 web pack 前端。它适用于前端资产。如果我尝试 webpack x-ray,我会遇到一系列问题,例如:

未找到模块:错误:无法解析 yadayadayada

因此,您可以像这样设置导出:

虽然这修复了模块错误,但我觉得我需要这些东西。在浏览器中我得到:

未捕获的错误:找不到模块“child_process”

我有一种感觉,这样的事情不应该起作用,但我希望我弄错了。

0 投票
2 回答
6022 浏览

javascript - Laravel Mix + Slick Carousel

我使用 laravel mix (webpack) 来编译我的项目。尝试添加 slick carousel 插件但出现错误:Uncaught TypeError: $(...).slick is not a function. 我使用文件中的.copy()方法webpack.mix.js从 node_modules 目录复制到公共目录:

所有文件都成功出现在适当的公共目录中,并且这些文件可以在源选项卡(在浏览器检查器中)中看到。

在我插入 slick 样式后,然后是 jquery(尝试了几个版本),然后是 html 头中的 slick.js。我什至使用了cdn url。如果我在没有 laravel mix 的情况下做同样的事情,那么光滑就可以了。

它不起作用,我不明白出了什么问题。请帮忙!

0 投票
0 回答
507 浏览

javascript - Laravel Mix 任务流程

我正在尝试在我webpack.mix.js的 laravel 项目中包含 browserSync。

问题是 browserSync 在其他任务执行之前重新加载浏览器。

仅在其他任务之后,我应该如何配置我webpack.mix.js的 for browserSync 重新加载页面?

这是我的 webpack.mix.js:

0 投票
1 回答
1119 浏览

javascript - 使用 mix 将 jquery 恒星插件添加到 laravel 5.4 项目

我是使用 Laravel Mix 的新手,我无法添加 jquery 库 stellar,当我尝试npm run dev时,它向我显示此错误:未找到此依赖项:* jquery.stellar in ./resources/assets/js/bootstrap。 js

但我已经使用npm install --save jquery.stellarnpm install jquery.stellar安装了它

这是我的 webpack 文件:webpack.mix.js:

应用程序.js:

引导程序.js

在我的 node_modules 目录中有一个 jquery.stellar 目录,其中包含 3 个文件:README.md、jquery.stellar.js、package.js

我不知道发生了什么,谢谢。