Angular正在生成数千个js文件

时间:2018-11-26 18:55:18

标签: javascript angular webpack angular-cli

我正在使用“ ng build --prod”命令生成一个用于生产的角度项目,但是在文件夹“ dist”中生成了许多.js文件(精确到1050个文件)

这正常吗?在其他项目中,这从未发生过

我的Angular-Cli版本是6.0.8,我的Angular版本是6.0.5

我留下一个屏幕快照,以查看我在说什么:

thousands of files

修改

我的路由文件:

root-routing.module.ts

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

const routes: Routes = [
    { path: '', redirectTo: '/app/home', pathMatch: 'full' },
    {
        path: 'account',
        loadChildren: 'account/account.module#AccountModule', //Lazy load account module
        data: { preload: true }
    },
    {
        path: 'app',
        loadChildren: 'app/app.module#AppModule', //Lazy load account module
        data: { preload: true }
    }
];

@NgModule({
    imports: [RouterModule.forRoot(routes)],
    exports: [RouterModule],
    providers: []
})
export class RootRoutingModule { }

app-routing.module.ts

import { StructListComponent} from './EstructurasLista/StructListComponent.component';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { AppComponent } from './app.component';
import { AppRouteGuard } from '@shared/auth/auth-route-guard';
import { HomeComponent } from './home/home.component';
import { AboutComponent } from './about/about.component';
import { UsersComponent } from './users/users.component';
import { TenantsComponent } from './tenants/tenants.component';
import { RolesComponent } from 'app/roles/roles.component';
import { CatComponent } from './Cat/Cat.component';

@NgModule({
    imports: [
        RouterModule.forChild([
            {
                path: '',
                component: AppComponent,
                children: [
                    { path: 'home', component: HomeComponent,  canActivate: [AppRouteGuard] },
                    { path: 'users', component: UsersComponent, data: { permission: 'Pages.Users' }, canActivate: [AppRouteGuard] },
                    { path: 'roles', component: RolesComponent, data: { permission: 'Pages.Roles' }, canActivate: [AppRouteGuard] },
                    { path: 'tenants', component: TenantsComponent, data: { permission: 'Pages.Tenants' }, canActivate: [AppRouteGuard] },
                    { path: 'about', component: AboutComponent }
                ]
            }            ,
            {
                path: 'f',
                component: AppComponent,
                children: [
                    { path: 'cat', component: CatComponent, data: { permission: 'Struct.Edit' }, canActivate: [AppRouteGuard] },
                    { path: 'structlist', component: StructListComponent, data: { permission: 'Struct.See' }, canActivate: [AppRouteGuard] },
                ]
            }
        ])
    ],
    exports: [RouterModule]
})
export class AppRoutingModule { }

account-routing.module.ts

import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { LoginComponent } from './login/login.component';
import { RegisterComponent } from './register/register.component';
import { AccountComponent } from './account.component';

@NgModule({
    imports: [
        RouterModule.forChild([
            {
                path: '',
                component: AccountComponent,
                children: [
                    { path: 'login', component: LoginComponent },
                    { path: 'register', component: RegisterComponent }
                ]
            }
        ])
    ],
    exports: [
        RouterModule
    ]
})
export class AccountRoutingModule { }

还有我的angular.json:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "Str": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist",
            "index": "src/index.html",
            "main": "src/main.ts",
            "tsConfig": "src/tsconfig.json",
            "polyfills": "src/polyfills.ts",
            "assets": [
              "src/assets",
              "src/favicon.ico",
              {
                "glob": "abp.signalr.js",
                "input": "node_modules/abp-web-resources/Abp/Framework/scripts/libs",
                "output": "/assets/abp"
              },
              {
                "glob": "abp.signalr-client.js",
                "input": "node_modules/abp-web-resources/Abp/Framework/scripts/libs",
                "output": "/assets/abp"
              }
            ],
            "styles": [
              "src/assets/fonts/roboto/roboto.css",
              "node_modules/bootstrap/dist/css/bootstrap.min.css",
              "node_modules/simple-line-icons/css/simple-line-icons.css",
              "node_modules/font-awesome/css/font-awesome.css",
              "node_modules/famfamfam-flags/dist/sprite/famfamfam-flags.css",
              "node_modules/toastr/build/toastr.css",
              "node_modules/node-waves/dist/waves.css",
              "src/bsb-theme/css/materialize.css",
              "src/bsb-theme/css/style.css",
              "src/bsb-theme/css/themes/all-themes.css",
              "src/shared/core.less",
              "src/styles/styles.css"
            ],
            "scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "node_modules/jquery-migrate/dist/jquery-migrate.min.js",
              "node_modules/js-cookie/src/js.cookie.js",
              "node_modules/bootstrap/dist/js/bootstrap.js",
              "node_modules/lodash/lodash.min.js",
              "node_modules/moment/min/moment.min.js",
              "node_modules/@aspnet/signalr/dist/browser/signalr.min.js",
              "node_modules/toastr/toastr.js",
              "node_modules/sweetalert/dist/sweetalert.min.js",
              "node_modules/block-ui/jquery.blockUI.js",
              "node_modules/spin.js/spin.min.js",
              "node_modules/spin.js/jquery.spin.js",
              "node_modules/push.js/bin/push.min.js",
              "node_modules/jquery-slimscroll/jquery.slimscroll.min.js",
              "node_modules/node-waves/dist/waves.min.js",
              "node_modules/jquery-countto/jquery.countTo.js",
              "node_modules/raphael/raphael.min.js",
              "node_modules/morris.js/morris.min.js",
              "node_modules/chart.js/dist/Chart.bundle.min.js",
              "node_modules/flot/jquery.flot.js",
              "node_modules/flot/jquery.flot.resize.js",
              "node_modules/flot/jquery.flot.pie.js",
              "node_modules/flot/jquery.flot.Strgories.js",
              "node_modules/flot/jquery.flot.time.js",
              "node_modules/jquery-sparkline/jquery.sparkline.min.js",
              "node_modules/abp-web-resources/Abp/Framework/scripts/abp.js",
              "node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.jquery.js",
              "node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.toastr.js",
              "node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.blockUI.js",
              "node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.spin.js",
              "node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.sweet-alert.js",
              "node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.moment.js",
              "src/bsb-theme/js/admin.js",
              "src/bsb-theme/js/demo.js",
              "src/bsb-theme/js/jquery.validate.js"
            ]
          },
          "configurations": {
            "production": {
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ]
            },
            "hmr": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.hmr.ts"
                }
              ]
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "Str:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "Str:build:production"
            },
            "hmr": {
              "browserTarget": "Str:build:hmr"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "Str:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "karmaConfig": "./karma.conf.js",
            "polyfills": "src/polyfills.ts",
            "scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "node_modules/jquery-migrate/dist/jquery-migrate.min.js",
              "node_modules/js-cookie/src/js.cookie.js",
              "node_modules/bootstrap/dist/js/bootstrap.js",
              "node_modules/lodash/lodash.min.js",
              "node_modules/moment/min/moment.min.js",
              "node_modules/@aspnet/signalr/dist/browser/signalr.min.js",
              "node_modules/toastr/toastr.js",
              "node_modules/sweetalert/dist/sweetalert.min.js",
              "node_modules/block-ui/jquery.blockUI.js",
              "node_modules/spin.js/spin.min.js",
              "node_modules/spin.js/jquery.spin.js",
              "node_modules/push.js/bin/push.min.js",
              "node_modules/jquery-slimscroll/jquery.slimscroll.min.js",
              "node_modules/node-waves/dist/waves.min.js",
              "node_modules/jquery-countto/jquery.countTo.js",
              "node_modules/raphael/raphael.min.js",
              "node_modules/morris.js/morris.min.js",
              "node_modules/chart.js/dist/Chart.bundle.min.js",
              "node_modules/flot/jquery.flot.js",
              "node_modules/flot/jquery.flot.resize.js",
              "node_modules/flot/jquery.flot.pie.js",
              "node_modules/flot/jquery.flot.Strgories.js",
              "node_modules/flot/jquery.flot.time.js",
              "node_modules/jquery-sparkline/jquery.sparkline.min.js",
              "node_modules/abp-web-resources/Abp/Framework/scripts/abp.js",
              "node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.jquery.js",
              "node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.toastr.js",
              "node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.blockUI.js",
              "node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.spin.js",
              "node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.sweet-alert.js",
              "node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.moment.js",
              "src/bsb-theme/js/admin.js",
              "src/bsb-theme/js/demo.js",
              "src/bsb-theme/js/jquery.validate.js"
            ],
            "styles": [
              "src/assets/fonts/roboto/roboto.css",
              "node_modules/bootstrap/dist/css/bootstrap.min.css",
              "node_modules/simple-line-icons/css/simple-line-icons.css",
              "node_modules/font-awesome/css/font-awesome.css",
              "node_modules/famfamfam-flags/dist/sprite/famfamfam-flags.css",
              "node_modules/toastr/build/toastr.css",
              "node_modules/node-waves/dist/waves.css",
              "src/bsb-theme/css/materialize.css",
              "src/bsb-theme/css/style.css",
              "src/bsb-theme/css/themes/all-themes.css",
              "src/shared/core.less",
              "src/styles/styles.css"
            ],
            "assets": [
              "src/assets",
              "src/favicon.ico",
              {
                "glob": "abp.signalr.js",
                "input": "node_modules/abp-web-resources/Abp/Framework/scripts/libs",
                "output": "/assets/abp"
              },
              {
                "glob": "abp.signalr-client.js",
                "input": "node_modules/abp-web-resources/Abp/Framework/scripts/libs",
                "output": "/assets/abp"
              }
            ]
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "src/tsconfig.json"
            ],
            "exclude": []
          }
        }
      }
    },
    "Str-e2e": {
      "root": "",
      "sourceRoot": "",
      "projectType": "application",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "./protractor.conf.js",
            "devServerTarget": "Str:serve"
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "e2e/tsconfig.json"
            ],
            "exclude": []
          }
        }
      }
    }
  },
  "defaultProject": "Str",
  "schematics": {
    "@schematics/angular:component": {
      "prefix": "app",
      "styleext": "css"
    },
    "@schematics/angular:directive": {
      "prefix": "app"
    }
  }
}

谢谢大家:)

0 个答案:

没有答案