Gulp不包括所有的javascript文件

时间:2016-04-22 18:43:10

标签: angularjs node.js gulp

我正在使用MEAN框架开发一个Web应用程序,并用于缩小文件。但是,应用程序不起作用,因为有很多"不是函数,未定义"当我检查导航仪控制台时。当我读到使用gulp生成的app.min.js文件时,我无法找到大多数javascripts文件(控制器,服务等)。

我正在为客户端使用的文件夹结构如下:

client/
├── app.min.js
├── app.min.js.map
├── controllers
│   ├── auth
│   │   ├── login_controller.js
│   │   └── register_controller.js
│   ├── home
│   │   └── home_controller.js
│   ├── navigation
│   │   └── navigation_controller.js
│   └── profile
│       └── profile_controller.js
├── directives
│   └── navigation.js
├── index.html
├── main.js
├── services
│   ├── authentication.js
│   └── data.js
└── views
    ├── auth
    │   ├── login
    │   │   └── login.html
    │   └── register
    │       └── register.html
    ├── home
    │   └── home.html
    ├── navigation
    │   └── navigation.html
    └── profile
        └── profile.html

这是我正在使用的gulp文件:

var gulp = require("gulp");
var concat = require("gulp-concat");
var uglify = require("gulp-uglify");
var watch = require("gulp-watch");
var sourcemaps = require("gulp-sourcemaps");
var ngHtml2Js = require("gulp-ng-html2js");

gulp.task("scripts", function() {
  gulp.src([
    "./client/**/*.js",
    "!./client/app.min.js"
  ]).pipe(sourcemaps.init())
      .pipe(concat("./app.min.js"))
      .pipe(uglify({mangle: true}))
      .pipe(gulp.dest("client"))
    .pipe(sourcemaps.write("./"))
    .pipe(gulp.dest("client"));
});

gulp.task("watch", function() {
  watch(["./client/**/*.js", "!./client/**/*.test.js", "!./client/app.min.js"], function() {
    gulp.start("scripts");
  });
});

gulp.task("default", ["scripts", "watch"]);

提前致谢。

修改

这是生成的app.min.js文件:

!function(){function t(t,e){t.when("/",{templateUrl:"views/home/home.html",controller:"homeCtrl",controllerAs:"vm"}).when("/register",{templateUrl:"views/register/register.html",controller:"registerCtrl",controllerAs:"vm"}).when("/login",{templateUrl:"views/login/login.html",controller:"loginCtrl",controllerAs:"vm"}).when("/profile",{templateUrl:"views/profile/profile.html",controller:"profileCtrl",controllerAs:"vm"}).otherwise({redirectTo:"/"}),e.html5Mode(!0)}function e(t,e,n){t.$on("$routeChangeStart",function(t,o,r){"/profile"!==e.path()||n.isLoggedIn()||e.path("/")})}angular.module("app",["ngRoute"]),angular.module("app").config(["$routeProvider","$locationProvider",t]).run(["$rootScope","$location","authentication",e])}(),function(){function t(){return{restrict:"EA",templateUrl:"/views/navigation/navigation.html",controller:"navigationCtrl as navvm"}}angular.module("app").directive("navigation",t)}(),function(){function t(t,e){var n=function(t){e.localStorage["token"]=t},o=function(){return e.localStorage["token"]},r=function(){var t,n=o();return n?(t=n.split(".")[1],t=e.atob(t),t=JSON.parse(t),t.exp>Date.now()/1e3):!1},i=function(){if(r()){var t=o(),n=t.split(".")[1];return n=e.atob(n),n=JSON.parse(n),{email:n.email,name:n.name}}},l=function(e){return t.post("/api/register",e).success(function(t){n(t.token)})},a=function(e){return t.post("/api/login",e).success(function(t){n(t.token)})},c=function(){e.localStorage.removeItem("token")};return{currentUser:i,saveToken:n,getToken:o,isLoggedIn:r,register:l,login:a,logout:c}}angular.module("app").service("authentication",t),t.$inject=["$http","$window"]}(),function(){function t(t,e){var n=function(){return t.get("/api/profile",{headers:{Authorization:"Bearer "+e.getToken()}})};return{getProfile:n}}angular.module("app").service("appData",t),t.$inject=["$http","authentication"]}(),function(){function t(t,e){var n=this;n.credentials={name:"",email:"",password:""},n.onSubmit=function(){console.log("Submitting registration"),e.register(n.credentials).error(function(t){alert(t)}).then(function(){t.path("profile")})}}angular.module("app").controller("registerCtrl",t),t.$inject=["$location","authentication"]}(),function(){function t(){console.log("Home controller is running")}angular.module("app").controller("homeCtrl",t)}(),function(){function t(t,e){var n=this;n.user={},e.getProfile().success(function(t){n.user=t}).error(function(t){console.log(t)})}angular.module("app").controller("profileCtrl",t),t.$inject=["$location","appData"]}();
//# sourceMappingURL=app.min.js.map

0 个答案:

没有答案