温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

怎么在angular-cli中利用webpack创建多个包

发布时间:2021-03-26 15:41:20 阅读:189 作者:Leah 栏目:web开发
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

今天就跟大家聊聊有关怎么在angular-cli中利用webpack创建多个包,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。

-cli.json中的配置

{
 "project": {
  "version": "1.0.0-beta.15",
  "name": "maddy-test-project"
 },
 "apps": [
  {
   "root": "src",
   "outDir": "dist",
   "assets": "styles/content",
   "index": "default.htm",
   "main": "main.ts",
   "test": "test.ts",
   "tsconfig": "tsconfig.json",
   "prefix": "",
   "mobile": false,
   "styles": [
    "styles.less"
   ],
   "scripts": [
    "styles/wfa-myriad-pro-typekit.js"
   ],
   "environments": {
    "source": "environments/environment.ts",
    "dev": "environments/environment.ts",
    "prod": "environments/environment.prod.ts"
   }
  }
 ],
 "addons": [],
 "packages": [],
 "e2e": {
  "protractor": {
   "config": "./protractor.conf.js"
  }
 },
 "test": {
  "karma": {
   "config": "./karma.conf.js"
  }
 },
 "defaults": {
  "styleExt": "less",
  "prefixInterfaces": false
 }
}

下面是package.json

{
 "name""maddy-test-project",
 "version""0.0.1",
 "license""MIT",
 "angular-cli": {},
 "scripts": {
  "start""ng serve",
  "lint""tslint \"src/**/*.ts\"",
  "test""ng test",
  "pree2e""webdriver-manager update",
  "e2e""protractor"
 },
 "private": true,
 "dependencies": {
  "@angular/common""2.0.0",
  "@angular/compiler""2.0.0",
  "@angular/core""2.0.0",
  "@angular/forms""2.0.0",
  "@angular/http""2.0.0",
  "@angular/platform-browser""2.0.0",
  "@angular/platform-browser-dynamic""2.0.0",
  "@angular/router""3.0.0",
  "d3""^4.2.3",
  "jquery""^3.1.0",
  "lodash""^4.15.0",
  "moment""^2.15.0",
  "core-js""^2.4.1",
  "rxjs""5.0.0-beta.12",
  "toastr""^2.1.2",
  "ts-helpers""^1.1.1",
  "zone.js""^0.6.23", 
  "bootstrap-daterangepicker""^2.1.24"
 },
 "devDependencies": {
  "@types/d3""^3.5.35",
  "@types/google-maps""^3.1.27",
  "@types/jasmine""^2.2.30",
  "@types/jquery""^1.10.31",
  "@types/lodash""^4.14.34",
  "@types/toastr""^2.1.29",
  "angular-cli""1.0.0-beta.15",
  "codelyzer""~0.0.26",
  "jasmine-core""2.4.1",
  "jasmine-spec-reporter""2.5.0",
  "karma""1.2.0",
  "karma-chrome-launcher""^2.0.0",
  "karma-cli""^1.0.1",
  "karma-jasmine""^1.0.2",
  "karma-remap-istanbul""^0.2.1",
  "protractor""4.0.5",
  "ts-node""1.2.1",
  "tslint""3.13.0",
  "typescript""2.0.2"
 }
}

提前致谢!!

它是NgModule和RouterModule.forChild()的作用.这是一个非常好的文章,用于启动大型角度2模块化应用开发: http://blog.angular-university.io/angular2-ngmodule/

The first thing that we need to do is to remove every mention of the Home component or the HomeModule from the App component and the main routing configuration:
We can see here that the App component no longer imports HomeModule, instead the routing config uses loadChildren to say that if /home or any other url starting with it gets hit, then the file home.module should be loaded via an Ajax call.

很快,为了在一个懒惰模块中移动一些逻辑和组件,您可以运行以下命令:

ng g module child --routing

然后angular-cli将生成一个NgModule(app / child / child.module.ts)和一个子路由器配置(app / child / child-routing.module.ts).

延迟加载此子路由器的路由将是:

{ path: 'child', loadChildren: 'app/child/child.module#ChildModule' }

看完上述内容,你们对怎么在angular-cli中利用webpack创建多个包有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注亿速云行业资讯频道,感谢大家的支持。

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI

开发者交流群×