如何使用gulp-inject修改脚本文件的路径

时间:2017-08-01 08:21:56

标签: angularjs gulp-inject

gulpfile.js

var myObject = window[classNameString];

的index.html

gulp.task('index', function() {
    var target = gulp.src('./app/index.html');
    // It's not necessary to read the files (will speed up things), we're only after their paths: 
    var sources = gulp.src(['./app/js/**/*.js'], {
        read: false
    });

    return target.pipe(inject(sources))
        .pipe(inject(gulp.src('./app/js/**/*.js', { read: false }, { ignorePath: '/app/' })))
        .pipe(gulp.dest('./build'));
});

我在这里得到<body ng-app="kisanApp"> <ng-view></ng-view> <!-- inject:js --> <script src="/app/js/app.js"></script> <script src="/app/js/directives.js"></script> <script src="/app/js/filters.js"></script> <script src="/app/js/services.js"></script> <script src="/app/js/controller/driverController.js"></script> <script src="/app/js/controller/driversController.js"></script> <!-- endinject --> </body> 而不是app/js/app.js。我应该如何修改我的路径以使其完美运行?

1 个答案:

答案 0 :(得分:2)

如果我理解正确,这将解决您的问题。

public function getBannedView(Request $request)
{
    $banCount = GameBan::where('ban_type', 'ip_ban')->where('ban_value', $request->ip())->whereRaw('expires_at > now()')->count();
    $banCountUsername = Auth::check() ? GameBan::where('ban_type', 'user_ban')->where('ban_value', Auth::user()->username)->whereRaw('expires_at > now()')->count() : 0;
    $banCountMachine = Auth::check() ? GameBan::where('ban_type', 'machine_ban')->where('ban_username', Auth::user()->username)->whereRaw('expires_at > now()')->count() : 0;

    if ($banCount < 1) {
        return redirect()->route("login");
    }

    return view('other.banned');
}