GithubHelp home page GithubHelp logo

sarvesh19 / angular2-sandbox Goto Github PK

View Code? Open in Web Editor NEW

This project forked from topheman/angular2-sandbox

0.0 2.0 0.0 3.21 MB

Mixing Angular2 and RxJS, using @ngrx/store for state management and Webpack for bundling

Home Page: https://topheman.github.io/angular2-sandbox/

JavaScript 27.55% TypeScript 44.87% HTML 14.26% CSS 13.32%

angular2-sandbox's Introduction

angular2-sandbox

Build Status

The goal of this project is to get better at Angular2, TypeScript and RxJS. I have a background on multiple projects with both Angular1 and React (with Redux), using Babel / Webpack and other tools.

To bootstrap this project, I've used my own boilerplate topheman/webpack-babel-starter that I have adapted from Babel / Eslint to TypeScript / TSLint.

This is still a work in progress. At this time, I've released an example of state management via @ngrx/store (a redux-like in RxJS), coupled with RxJS Observable streams wired to Angular2 components. The next step will be to add some network requests involved.

I've kept the development workflow exactly the same as topheman/webpack-babel-starter's (build tasks, deployment ...).

What's in there ?

ONLINE DEMO

###Install

git clone https://github.com/topheman/angular2-sandbox.git
cd angular2-sandbox
npm install

###Run

npm start

Goto http://localhost:8080

If you need to access from a remote device (such as a smartphone on the same network), just LOCALHOST=false npm start and your site will be accessible via your IP (which will be output on the terminal at launch).

###Build

The ./build directory is ignored by git, it will contain a dist directory which holds the distribution version of your website (the one that you will ship once built (more infos on topheman/webpack-babel-starter).

All the build tasks will create a built version of the project in the ./build/dist folder, cleaning it before making the build.

  • npm run build
  • npm run build-prod optimized / uglified version
  • npm run build-prod-all will build:
    • production version (optimized / uglified)
    • a debuggable version accessible at /devtools shipping all the sourcemaps, to ease sharing transpiled source code

npm run serve-dist will serve your ./build/dist folder at http://localhost:3000 so that you could test the built version you just made.

Development modules such as ngrx/devtools or any loggers that are used to enhance developer's experience won't even be part of the final production bundle. They will be dropped after compilation step, thanks to webpack.DefinePlugin. This isn't as straightforward and clean as with webpack/Babel/ES6 (because of TypeScript typing system and Angular decorators) - see the issue.

###Linter

  • tslint is running while you're developping, check your console for errors
  • you can also launch it via npm run lint
  • see tslint.json for the configuration, inspired by AngularClass/angular2-webpack-starter's

###Customizations

You can customize the behavior of the scripts by specifying environments vars like DEVTOOLS, SHOW_DEVTOOLS, NODE_ENV or LINTER:

  • NODE_ENV by default at development, NODE_ENV=production when you npm run build-prod
  • LINTER=false will disable the linter (enabled by default, ex: LINTER=false npm start)
  • STATS=true will write stats.json profiling file on disk from webpack at build (disabled by default, ex: STATS=true npm run build)
  • FAIL_ON_ERROR=true will break the build if any errors occurs (useful for CIs such as travis - at false in dev-server, at true when building)
  • LOCALHOST=false to access via IP from other devices on the same network (ex: LOCALHOST=false npm start - default true)
  • DEVTOOLS: By default at null. Used internally by npm run build-prod-all (you may not need that if you don't do OSS)
  • SHOW_DEVTOOLS=false npm start lets you run with the devtools closed by default
  • DEVTOOLS npm run webpack lets you run without the devtools
  • By default the project is using awesome-typescript-loader (for better performance in development with watch mode and other things), you can get back to ts-loader, just setting AWESOME_LOADER=false - ex: AWESOME_LOADER=false npm start

###More

More infos about the workflow on topheman/webpack-babel-starter (slight difference: this project uses TypeScript / TSLint over Babel / ESLint ๐Ÿ˜‰).

Copyright 2016 ยฉ Christophe Rosset

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. The Software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the Software.

angular2-sandbox's People

Contributors

topheman avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.