Skip to content

jrzerr/angular2-webpack-tsheets-api-demo

Repository files navigation

Zerrtech instructions

Create a .env file in the project root that has configuration parameters:

Then within the app you can access them via process.env.API_URL anywhere without doing imports or anything.

API_URL is the url to a server that will forward requests to the TSheets API that is not CORS enabled

ACCESS_TOKEN is a one off access token that you create within the TSheets web dashboard in the API section

angular2-webpack

Dependency Status devDependency Status

Note: This guide is following the Angular's Style Guide so I will be changing conventions here and there eventually. You are free to use your own conventions with this starter.

A complete, yet simple, starter for Angular 2 using Webpack.

This seed repo serves as an Angular 2 starter for anyone looking to get up and running with Angular 2 and TypeScript fast. Using Webpack for building our files and assisting with boilerplate. We're also using Protractor for our end-to-end story and Karma for our unit tests.

Warning: Make sure you're using the latest version of Node.js and NPM

Is Angular 2 Ready Yet?

Quick start

Clone/Download the repo then edit app.ts inside /src/app/app.component.ts to change the Component selector to match whatever you would like your top level component called in the src/public/index.html file.

Get nvm installed

# clone our repo
$ git clone https://github.com/preboot/angular2-webpack.git my-app

# change directory to your app
$ cd my-app

# use the proper version of nodejs
$ nvm install

# install the dependencies with npm
$ npm install

# add a .env file that contains config parameters
$ touch .env
# go and add the following contents to the file, see notes in README for what they are for
API_URL=http://127.0.0.1:8080
ACCESS_TOKEN=blahblahblah

# start the server
$ npm start

go to http://localhost:8080 in your browser.

Table of Contents

Getting Started

Dependencies

What you need to run this app:

  • node and npm (Use NVM)
  • Ensure you're running Node (v5.x.x+) and NPM (3.x.x+)

Installing

  • fork this repo
  • clone your fork
  • npm install to install all dependencies

Running the app

After you have installed all dependencies you can now run the app with:

npm start

It will start a local server using webpack-dev-server which will watch, build (in-memory), and reload for you. The port will be displayed to you as http://localhost:8080.

Developing

Build files

  • single run: npm run build
  • build files and watch: npm run watch

Testing

1. Unit Tests

  • single run: npm test
  • live mode (TDD style): npm run test-watch

2. End-to-End Tests (aka. e2e, integration)

  • single run:
    • in a tab, if not already running!: npm start
    • in a new tab: npm run webdriver-start
    • in another new tab: npm run e2e
  • interactive mode:
    • instead of the last command above, you can run: npm run e2e-live
    • when debugging or first writing test suites, you may find it helpful to try out Protractor commands without starting up the entire test suite. You can do this with the element explorer.
    • you can learn more about Protractor Interactive Mode here

Documentation

You can generate api docs (using TypeDoc) for your code with the following:

npm run docs

FAQ

Do I need to add script / link tags into index.html ?

No, Webpack will add all the needed Javascript bundles as script tags and all the CSS files as link tags. The advantage is that you don't need to modify the index.html every time you build your solution to update the hashes.

How to include external angular 2 libraries ?

It's simple, just install the lib via npm and import it in your code when you need it. Don't forget that you need to configure some external libs in the bootstrap of your application.

How to include external css files such as bootstrap.css ?

Just install the lib and import the css files in vendor.ts. For example this is how to do it with bootstrap:

npm install [email protected] --save

And in vendor.ts add the following:

import 'bootstrap/dist/css/bootstrap.css';

TypeScript

To take full advantage of TypeScript with autocomplete you would have to use an editor with the correct TypeScript plugins.

Use a TypeScript-aware editor

We have good experience using these editors:

License

MIT