gpt4 book ai didi

javascript - Laravel Gulp 未创建 js 文件夹

转载 作者:行者123 更新时间:2023-12-02 15:33:33 25 4
gpt4 key购买 nike

我目前正在尝试让 gulp 在我的 Laravel 项目上运行。

我可以在我的 app.scss 上成功运行 gulp

我正在尝试在测试 CoffeeScript 上运行 gulp, CoffeeScript 位于资源> Assets >咖啡> test.coffee中

这是我的 gulpfile.js

var elixir = require('laravel-elixir');

/*
|--------------------------------------------------------------------------
| Elixir Asset Management
|--------------------------------------------------------------------------
|
| Elixir provides a clean, fluent API for defining some basic Gulp tasks
| for your Laravel application. By default, we are compiling the Sass
| file for our application, as well as publishing vendor resources.
|
*/

elixir(function(mix) {
mix.sass('app.scss');
mix.coffee();
});

当我运行 gulp 时,出现此错误。

fetching Sass Source Files...
- resources/assets/sass/app.scss


Saving To...
- public/css/app.css

[23:08:58] Finished 'default' after 313 ms
[23:08:58] gulp-notify: [Laravel Elixir] Sass Compiled!
[23:08:58] Finished 'sass' after 403 ms
[23:08:58] Starting 'coffee'...
[23:08:58] 'coffee' errored after 311 μs
[23:08:58] TypeError: Cannot call method 'indexOf' of undefined
at prefixOne (/home/pocockn/projects/dev.todoparrot.com/node_modules/laravel-elixir/GulpPaths.js:104:18)
at GulpPaths.prefix (/home/pocockn/projects/dev.todoparrot.com/node_modules/laravel-elixir/GulpPaths.js:124:12)
at GulpPaths.src (/home/pocockn/projects/dev.todoparrot.com/node_modules/laravel-elixir/GulpPaths.js:24:16)
at prepGulpPaths (/home/pocockn/projects/dev.todoparrot.com/node_modules/laravel-elixir/tasks/coffee.js:55:10)
at null.definition (/home/pocockn/projects/dev.todoparrot.com/node_modules/laravel-elixir/tasks/coffee.js:21:21)
at Task.run (/home/pocockn/projects/dev.todoparrot.com/node_modules/laravel-elixir/Task.js:96:17)
at Gulp.<anonymous> (/home/pocockn/projects/dev.todoparrot.com/node_modules/laravel-elixir/index.js:94:52)
at module.exports (/home/pocockn/projects/dev.todoparrot.com/node_modules/orchestrator/lib/runTask.js:34:7)
at Gulp.Orchestrator._runTask (/home/pocockn/projects/dev.todoparrot.com/node_modules/orchestrator/index.js:273:3)
at Gulp.Orchestrator._runStep (/home/pocockn/projects/dev.todoparrot.com/node_modules/orchestrator/index.js:214:10)
[23:08:58] Error in plugin 'run-sequence'
Message:
An error occured in task 'coffee'.

还有其他人遇到过这个错误吗?

最佳答案

您没有指定 CoffeeScript 的名称,因此 Elixir 不知道它需要编译什么文件。您唯一需要做的就是在大括号之间指定脚本的名称,如下所示:

elixir(function(mix) {
mix.coffee('test.coffee');
});

还有一种叫做方法链的东西。这将允许您同时运行多个任务。如果添加 Sass,您的代码应如下所示:

elixir(function(mix) {
mix.sass('app.scss')
.coffee('test.coffee');
});

您可以随时查看 laravel 文档以获取有关 Elixir 的更多信息 here .

关于javascript - Laravel Gulp 未创建 js 文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33136518/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com