Laravel elixir 5.2不会在扩展任务中组合脚本

时间:2018-01-06 12:13:36

标签: laravel gulp laravel-elixir

我在gulpfile.js中的代码是:

我想像(gulp用户)创建gulp命令来混合脚本和样式,如下所示,但这不起作用,


elixir.config.assetsPath = '';
elixir.config.js.folder = '';
var Task = elixir.Task;
var Mix = elixir.mixins;

elixir.extend('user', function () {

    new Task('user', function () {

        Mix.scripts(
            [
                '/resources/assets/js/angular/user/app/',
                '/resources/assets/js/angular/user/main/',
                '/resources/assets/js/angular/user/configs/',
                '/public/app/user/libs/angular/ui-bootstrap/ui-bootstrap-custom-2.0.0.js',
                '/resources/assets/js/angular/user/models/',
                '/public/app/libs/angular/ng-typeahead/dist/ng-typeahead.js',
                '/resources/assets/js/angular/user/controllers/',
                'public/app/libs/angular/angularjs-toaster/toaster.js',
                '/resources/assets/js/angular/user/filters/',
                '/resources/assets/js/angular/admin/directives/googlemap/map.js',
                '/public/app/libs/assets/custom-lodash.js',
                '/resources/assets/js/angular/user/services/',
                '/resources/assets/js/angular/user/directives/',
                '/public/app/user/assets/js/bootstrap.3.3.5.js',
                '/public/app/user/assets/js/ui-bootstrap-tpls-2.0.0.js',
                '/public/app/user/assets/js/slick.js',
                '/public/app/user/assets/js/angular-slick.min.js',
                '/public/app/user/assets/js/bootstrap-chosen.js',
                '/public/app/user/assets/js/fixto.min.js',
                '/public/app/user/ngApp/templates/templates.js'
            ],
            'public/app/user/ngApp/scripts/app-all.js'
        ).sass(
            [
                './public/app/user/assets/sass/main.scss'
            ],
            './public/app/user/assets/css/kit.css'
        ).styles(
            [
                './public/app/user/assets/css/bootstrap.css',
                './public/app/user/assets/css/font.css',
                './public/app/user/assets/css/kit.css',
                './public/app/user/assets/css/range-slider.css',
                './public/app/user/assets/css/angular-bootstrap-lightbox.css',
                './public/app/libs/angular/angularjs-toaster/toaster.css',
                './public/app/libs/angular-rateit/dist/rateit.css',
                './public/app/libs/angular/ng-typeahead/dist/ng-typeahead.css',
                './public/app/user/assets/css/app.css',
                './public/app/user/assets/css/nga.all.min.css',
                './public/app/user/assets/css/rzslider.css',
                './public/app/user/assets/css/slick.css',
                './public/app/user/assets/css/slick-theme.css',
                './public/app/user/assets/css/animate.css',
                './public/app/user/libs/jquery/select2/dist/css/select2.min.css'
            ],
            './public/app/user/assets/css/app-all.css'
        ).version(
            [
                'public/app/user/assets/css/app-all.css',
                'public/app/user/ngApp/scripts/app-all.js'
            ]
        );
    });
});

当我在终端中运行( gulp user )时,结果为空,如下所示, 混合不能正常工作并结合脚本和样式

[15:20:00] Using gulpfile /var/www/chilivery/web/gulpfile.js
[15:20:00] Starting 'user'...
┌────────────┬─────────┬──────────────┬─────────────┐
│ Task       │ Summary │ Source Files │ Destination │
├────────────┼─────────┼──────────────┼─────────────┤
│ mix.user() │         │
└────────────┴─────────┴──────────────┴─────────────┘
[15:20:00] Finished 'user' after 6.36 ms

任何帮助请问,我如何创建像gulp用户一样的gulp命令来处理它?<​​/ p>

1 个答案:

答案 0 :(得分:1)

让我们忘记&#34;自定义任务&#34;第一部分。

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


elixir(function(mix) {
    mix.scripts(
            [
                'resources/assets/js/angular/user/app/',
                'resources/assets/js/angular/user/main/',
                'resources/assets/js/angular/user/configs/',
                'public/app/user/libs/angular/ui-bootstrap/ui-bootstrap-custom-2.0.0.js',
                'resources/assets/js/angular/user/models/',
                'public/app/libs/angular/ng-typeahead/dist/ng-typeahead.js',
                'resources/assets/js/angular/user/controllers/',
                'public/app/libs/angular/angularjs-toaster/toaster.js',
                'resources/assets/js/angular/user/filters/',
                'resources/assets/js/angular/admin/directives/googlemap/map.js',
                'public/app/libs/assets/custom-lodash.js',
                'resources/assets/js/angular/user/services/',
                'resources/assets/js/angular/user/directives/',
                'public/app/user/assets/js/bootstrap.3.3.5.js',
                'public/app/user/assets/js/ui-bootstrap-tpls-2.0.0.js',
                'public/app/user/assets/js/slick.js',
                'public/app/user/assets/js/angular-slick.min.js',
                'public/app/user/assets/js/bootstrap-chosen.js',
                'public/app/user/assets/js/fixto.min.js',
                'public/app/user/ngApp/templates/templates.js'
            ],
            'public/app/user/ngApp/scripts/app-all.js'
        );
    mix.styles(
            [
                'public/app/user/assets/css/bootstrap.css',
                'public/app/user/assets/css/font.css',
                'public/app/user/assets/css/kit.css',
                'public/app/user/assets/css/range-slider.css',
                'public/app/user/assets/css/angular-bootstrap-lightbox.css',
                'public/app/libs/angular/angularjs-toaster/toaster.css',
                'public/app/libs/angular-rateit/dist/rateit.css',
                'public/app/libs/angular/ng-typeahead/dist/ng-typeahead.css',
                'public/app/user/assets/css/app.css',
                'public/app/user/assets/css/nga.all.min.css',
                'public/app/user/assets/css/rzslider.css',
                'public/app/user/assets/css/slick.css',
                'public/app/user/assets/css/slick-theme.css',
                'public/app/user/assets/css/animate.css',
                'public/app/user/libs/jquery/select2/dist/css/select2.min.css'
            ],
            'public/app/user/assets/css/app-all.css'
        );

    mix.version(
            [
                'public/app/user/assets/css/app-all.css',
                'public/app/user/ngApp/scripts/app-all.js'
            ]
        );

});

这里没有自定义任务用户,路径总是相似的(前面没有/或./),我们已经避免链接调用混合函数 - 所有这些都是为了调试并尝试制作你的代码工作

你得到了什么结果?您的控制台/终端有什么输出?你有什么输出

  • 公共/应用/用户/ ngApp /脚本/ APP-all.js
  • 公共/应用/用户/资产/ CSS / kit.css
  • 和public / app / user / assets / css / app-all.css