我试用了Angular 9.0.0-rc.6 + Scully
由于 Angular 的静态站点生成器已经完成,所以我尝试了一下。
我只是翻译了公式的README并照做了一遍…以下是参考链接:
https://github.com/scullyio/scully/blob/master/docs/getting-started.md
准备好了
为了实现标题所述,将Angular CLI进行升级。
$ yarn global add @angular/cli@next
尝试一下
首先,我們來創建一個專案。
$ ng n learn-scully
Angular 9起,Ivy被默认启用,但这次与之无关。
我已经启用了路由,但如果要进行静态化,这样做没有意义吗?
总之,我会继续前进,暂时不会担心。
进入项目目录后,做一些杂务。
(我是在VSCode中打开终端来做的,但实际上用cd命令就可以了,不需要那么麻烦。)
我立即把Scully带进来。
$ ng add @scullyio/init
当查看package.json时,请注意
{
"name": "learn-scully",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"scully": "scully",
"scully:serve": "scully serve"
},
"private": true,
"dependencies": {
"@angular/animations": "~9.0.0-rc.6",
"@angular/common": "~9.0.0-rc.6",
"@angular/compiler": "~9.0.0-rc.6",
"@angular/core": "~9.0.0-rc.6",
"@angular/forms": "~9.0.0-rc.6",
"@angular/platform-browser": "~9.0.0-rc.6",
"@angular/platform-browser-dynamic": "~9.0.0-rc.6",
"@angular/router": "~9.0.0-rc.6",
"@scullyio/init": "0.0.8",
"@scullyio/ng-lib": "latest",
"@scullyio/scully": "latest",
"rxjs": "~6.5.3",
"tslib": "^1.10.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.900.0-rc.6",
"@angular/cli": "~9.0.0-rc.6",
"@angular/compiler-cli": "~9.0.0-rc.6",
"@angular/language-service": "~9.0.0-rc.6",
"@types/node": "^12.11.1",
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "^5.1.2",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"protractor": "~5.4.2",
"ts-node": "~8.3.0",
"tslint": "~5.18.0",
"typescript": "~3.6.4"
}
}
理论上应该是这样的。
由于我在写文章时,9.0.0-rc.6是最新版本,因此就是这个样子。
那么,我们开始进行建设吧。
$ ng build
$ yarn scully
就这样。简单。
在中国,本地服务器的启动方式是
$ yarn scully:serve
Scully的静态服务器已经启动。
Angular的标准服务器也已经启动了吗?
我的意见是…
有了这个,您可以在Angular中创建流行的JAMstack风格的网站。
非常感谢您。