Upgrading from Beta.10 to Beta.14
We changed the build system between beta.10 and beta.14, from SystemJS to Webpack. And with it comes a lot of benefits. To take advantage of these, your app built with the old beta will need to migrate.
This page documents the steps to follow to migrate your old application to using the newest beta.
Steps to Migrate
This guide assumes your application is using SystemJS created with the beta.10
and is up to date to >= Angular RC6
. Also, make sure you committed everything from your project to Git.
-
Upgrade to the latest CLI globally:
npm uninstall -g angular-cli npm cache clean npm install -g angular-cli@latest
-
Create a new migration project:
ng new migration-project
-
Backup the new
src/
to a different folder. We need those files later on.mv src/ src.webpacktemplate/
-
Replace the
src/
folder with your application'ssrc/
folder.mv ${OLD_PATH}/src src
-
Replace the
e2e/
folder with your application'se2e/
folder.mv ${OLD_PATH}/e2e e2e
-
Delete files that are not needed anymore.
rm src/system-config.ts rm src/typings.d.ts
-
Copy files that are needed from a new project.
cp src.webpacktemplate/polyfills.ts src/ cp src.webpacktemplate/styles.css src/ cp src.webpacktemplate/test.ts src/ cp src.webpacktemplate/tsconfig.json src/ cp src.webpacktemplate/typings.d.ts src/
-
In most cases, you can override your
src/main.ts
with the one insrc.webpacktemplate/main.ts
, but you might want to be careful if you have custom modifications to it. -
In most cases, you can override your
src/index.html
with the one insrc.webpacktemplate/index.html
, but you might want to be careful if you have custom modifications to it. -
Copy over your environment files. These are now part of the app and not in the root of your repo, and
environment.dev.ts
is now justenvironment.ts
.mv ${OLD_PATH}/config/environment.dev.ts src/environments/environment.ts mv ${OLD_PATH}/config/environment.prod.ts src/environments/environment.prod.ts
If you have any custom environments don't forget to move them too.
Environments are now listed in the angular-cli.json. Make sure those files matches the files on your disk. More importantly, because they're part of your application, their paths are relative to your
main.ts
. -
Install npm dependencies that you were using. These may include (but not limited to):
- Angular Material 2 (need HammerJS typings)
- Angularfire2
- Bootstrap
- Firebase
- jQuery
- Moment
- ...
npm install --save ${LIBRARY}
These libraries might have typings necessary, which you can install using:
npm install --save-dev @types/${LIBRARY}
Remember to copy any configuration or documentation files you have. For example, you might have a
firebase.json
file in the root of your repo. Don't forget yourLICENSE
andREADME.md
file! -
Remove all mention of
moduleId: module.id
. In webpack,module.id
is a number but Angular expect a string. -
Copy over your assets directory. Assets are now part of the app and not in the root of your repo.
cp -R ${OLD_PATH}/public/ src/assets/
Make sure to also remap your assets in your code. The new assets are served from
/assets/
. -
Finally, if you're using SASS or LESS, you need to rename your
styleUrls
in all your files. Webpack understands LESS and SASS so you can usestyleUrls: ['my-component.scss']
in your component and it will be transcompiled automatically. -
After all this, make sure you don't need anything else from the
src.webpacktemplate/
directory, try tong build
. If everything works, chances are you're good to go. Delete thesrc.webpacktemplate/
directory. -
Time to replace the git folder so you don't lose your history. Delete the
.git/
file in the new migration project. Then copy over your old.git/
folder to replace it.rm -rf .git/ cp -R ${OLD_PATH}/.git .
-
Go ahead and
ng serve
your app, then look at the resulting website. Adjust and adapt your code according to errors.
相关推荐
Angular-angular-cli.zip,用于angularangular cli的cli工具,Angularjs于2016年发布,是Angularjs的重写版。它专注于良好的移动开发、模块化和改进的依赖注入。angular的设计目的是全面解决开发人员的web应用程序工作...
Netty的现Tech Lead Norman在本书中循序渐进地讲解了Netty的各个关键部分,在看完本书后,你不但可以熟练地使用Netty来构建以上系统,并且还可以避免很多常见的陷阱。 无论是想要学习Spring 5 、Spark、Cassandra...
前台Web开发框架Angular介绍,安装Angular Cli,使用VSCode工具创建第一个Angular项目,并编译运行
**Angular CLI升级指南** 在Angular开发中,Angular CLI(命令行接口)扮演着至关重要的角色,它简化了项目创建、构建、测试和部署的过程。随着Angular框架的不断更新,CLI工具也会随之迭代,以保持与最新功能的...
创建Angular项目时,CLI会生成一个基础项目结构,包括源代码、测试文件、配置文件等。项目的核心是`app.module.ts`,它是应用的主要模块,用于注册组件、指令和服务。同时,`app.component.ts`是默认的根组件,定义...
在开发基于Angular框架的应用时,Angular CLI(命令行接口)是一个不可或缺的工具,它极大地简化了项目的初始化、构建、测试和部署流程。本篇文章将详细解释如何在Angular 2环境中安装和使用Angular CLI。 首先,...
Angular CLI创建,管理,构建和测试Angular项目。 它建立在Angular DevKit之上。 DevKit的目标 DevKit的目标是提供大量可用于管理,开发,部署和分析代码的库。 入门-本地开发 安装 要在本地开始使用,请按照以下...
在本教程中,我们将深入探讨如何使用Angular CLI生成Angular 5项目。Angular CLI(命令行接口)是一个强大的工具,能够简化Angular应用的开发流程,包括项目初始化、组件创建、服务生成以及构建和测试等任务。 首先...
- **初始化**: 使用 Angular CLI 或手动创建项目结构,配置 TypeScript 编译和模块加载器。 - **编写组件**: 创建组件类和模板,定义属性、方法和事件处理。 - **服务化数据**: 创建服务来处理 HTTP 请求或其他...
这是本人在练习angular时,边学便用写的例子,文章参考http://blog.csdn.net/yiershan1314/article/details/78027872
Angular-angular-cli-webpack.zip,@angular/cliangular cli webpack(ngw)的webpack配置修饰符,Angularjs于2016年发布,是Angularjs的重写版。它专注于良好的移动开发、模块化和改进的依赖注入。angular的设计目的...
在进行Angular项目的升级之前,确保当前环境中已经安装了Angular 7.1版本。这一步非常重要,因为后续的升级步骤将基于此版本进行。 #### 二、升级步骤 ##### 1. 更新全局Angular CLI 在项目根目录下运行以下命令...
Angular CLI(命令行接口)是Angular开发中的一个强大工具,它提供了一种快速、高效的方式来创建、构建和管理Angular项目。然而,尽管CLI提供了许多预设的配置,但有时我们可能需要根据项目需求进行自定义设置。这时...
2. **生成Angular2项目**:在Laravel项目内,使用Angular CLI生成一个新的Angular2项目。这一步可以自定义项目名称和目录位置,以适应Laravel的结构。 3. **配置API接口**:在Laravel中定义RESTful API接口,供...