-
Notifications
You must be signed in to change notification settings - Fork 0
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.
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
-
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.