使用gulp-inject执行gulp任务时出错

时间:2017-06-27 04:28:21

标签: gulp

我在gulp taks中得到以下错误,请告知如何克服这一点,下面是我吞咽的gulp-inject

gulp.task('injectjsp', function(){

    var resourcesToInject =  gulp.src(
        [sourcePaths.build + 'C:\\Softwares\\Spring4MVCAngularJSExample\\src\\main\\webapp\\static\\*.js'],
        {read: false});

    return gulp
        .src('C:\\Softwares\\Spring4MVCAngularJSExample\\src\\main\\webapp\\WEB-INF\\views\\UserManagement2.jsp')
        .pipe(inject(
          resourcesToInject,{
                transform: transoformResourceInclude
            }
          )
        )
        .pipe(gulp.dest('C:\\Softwares\\Spring4MVCAngularJSExample\\src\main\\webapp\\WEB-INF\\views\\'));
    });


    function transoformResourceInclude(filePath){


    var path = filePath.split('/').filter(function(slicePath){
        return slicePath != '' &&
            slicePath != 'src' && slicePath != 'main'
            && slicePath != 'webapp';
    });

    return  '<script src="<c:url value="/'+ path.join('/') +'" />"></script>';
    }

我现在收到的错误如下所示,请告知如何克服此错误

C:\Softwares\Spring4MVCAngularJSExample>gulp injectjsp
[09:52:36] Using gulpfile C:\Softwares\Spring4MVCAngularJSExample\gulpfile.js
[09:52:36] Starting 'injectjsp'...
[09:52:36] 'injectjsp' errored after 388 μs
[09:52:36] ReferenceError: sourcePaths is not defined
    at Gulp.<anonymous> (C:\Softwares\Spring4MVCAngularJSExample\gulpfile.js:60:7)
    at module.exports (C:\Softwares\Spring4MVCAngularJSExample\node_modules\orchestrator\lib\runTask.js:34:7)
    at Gulp.Orchestrator._runTask (C:\Softwares\Spring4MVCAngularJSExample\node_modules\orchestrator\index.js:273:3)
    at Gulp.Orchestrator._runStep (C:\Softwares\Spring4MVCAngularJSExample\node_modules\orchestrator\index.js:214:10)
    at Gulp.Orchestrator.start (C:\Softwares\Spring4MVCAngularJSExample\node_modules\orchestrator\index.js:134:8)
    at C:\Users\saral.saxena\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:129:20
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickCallback (internal/process/next_tick.js:104:9)
    at Module.runMain (module.js:606:1

0 个答案:

没有答案