我试图设置一个使用angular-cli创建的基本角度应用程序,使用aot编译。很难弄清楚main.ts文件应该是什么样子才能引导应用程序,因为angular-cli隐藏了tsconfig.json文件,我找不到相关文档描述如何执行此操作。有人可以帮我正确设置吗?
我的ng version
是
angular-cli: 1.0.0-beta.25.5 │127.0.0.1 - - [18/Jan/2017 12:09:31] "GET /main.bundle.map HTTP/1.1" 200 -
node: 7.4.0 │^C
os: linux x64 │Keyboard interrupt received, exiting.
@angular/common: 2.4.3 │joi ~/workspace/angular2/testing/dist $ cd ..
@angular/compiler: 2.4.3 │joi ~/workspace/angular2/testing $ cd dis
@angular/core: 2.4.3 │-bash: cd: dis: No such file or directory
@angular/forms: 2.4.3 │joi ~/workspace/angular2/testing $ cd dist
@angular/http: 2.4.3 │-bash: cd: dist: No such file or directory
@angular/platform-browser: 2.4.3 │joi ~/workspace/angular2/testing $ cd dist
@angular/platform-browser-dynamic: 2.4.3 │joi ~/workspace/angular2/testing/dist $ ls
@angular/router: 3.4.3 │assets inline.bundle.js main.bundle.map vendor.bundle.js
@angular/compiler-cli: 2.4.3
package.json文件是:
{
"name": "testing",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"ng": "ng",
"start": "ng serve",
"lint": "tslint \"src/**/*.ts\" --project src/tsconfig.json --type-check && tslint \"e2e/**/*.ts\" --project e2e/tsconfig.json --type-check",
"test": "ng test",
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"@angular/common": "^2.3.1",
"@angular/compiler": "^2.3.1",
"@angular/core": "^2.3.1",
"@angular/forms": "^2.3.1",
"@angular/http": "^2.3.1",
"@angular/platform-browser": "^2.3.1",
"@angular/platform-browser-dynamic": "^2.3.1",
"@angular/router": "^3.3.1",
"core-js": "^2.4.1",
"rxjs": "^5.0.1",
"ts-helpers": "^1.1.1",
"zone.js": "^0.7.2"
},
"devDependencies": {
"@angular/compiler-cli": "^2.3.1",
"@types/jasmine": "2.5.38",
"@types/node": "^6.0.42",
"angular-cli": "1.0.0-beta.25.5",
"codelyzer": "~2.0.0-beta.1",
"jasmine-core": "2.5.2",
"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.13",
"ts-node": "1.2.1",
"tslint": "^4.3.0",
"typescript": "~2.0.3"
}
}
main.ts文件目前看起来像这样:
import './polyfills.ts';
import { platformBrowser } from '@angular/platform-browser';
import { AppModuleNgFactory } from './app/app.module.ngfactory';
platformBrowser().bootstrapModuleFactory(AppModuleNgFactory);
答案 0 :(得分:1)
创建项目:
ng new super-project
构建您的项目:
ng build
使用AoT构建您的项目:
ng build --aot
<强> CELEBRATE !!! 强>
您无需进行额外配置。