├── .gitignore ├── LICENCE ├── README.md ├── bs-config.json ├── gulpfile.ts ├── package.json ├── src ├── app │ ├── about │ │ └── components │ │ │ ├── about.component.ts │ │ │ └── about.html │ ├── app.component.ts │ ├── app.html │ ├── app.module.ts │ ├── app.routing.ts │ ├── main.ts │ └── todo │ │ ├── components │ │ ├── task-list.component.ts │ │ ├── task-list.css │ │ ├── task-list.html │ │ ├── task.component.ts │ │ └── task.html │ │ ├── models │ │ └── task.ts │ │ └── services │ │ └── task-service.ts ├── index.html └── systemjs.config.js ├── tsconfig.json ├── tslint.json └── typings.json /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | build 3 | node_modules 4 | typings -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Rafal Borowiec 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Angular2 with TypeScript and Gulp 2 | ================================= 3 | 4 | A basic Angular2 application with Gulp as build system. 5 | 6 | #### 1. Prerequisites 7 | 8 | *nodejs* must be installed on your system and the below global node packages must be installed: 9 | 10 | - gulp 11 | 12 | > npm i -g gulp 13 | 14 | - gulp-cli 15 | 16 | > npm i -g gulp-cli 17 | 18 | - typings 19 | 20 | > npm i -g typings@1.3.3 21 | 22 | - typescript 23 | 24 | > npm i -g typescript@2.0.2 25 | 26 | - ts-node 27 | 28 | > npm i -g ts-node@1.3.0 29 | 30 | #### 2. Cloning the repository 31 | 32 | Clone the repository: 33 | 34 | > git clone https://github.com/kolorobot/angular2-typescript-gulp.git 35 | 36 | Navigate to `angular2-typescript-gulp` directory: 37 | 38 | > cd angular2-typescript-gulp 39 | 40 | #### 3. Installing dependencies 41 | 42 | Install dependencies by running the following command: 43 | 44 | > npm install 45 | 46 | `node_modules` and `typings` directories will be created during the install. 47 | 48 | #### 4. Building the project 49 | 50 | Build the project by running the following command: 51 | 52 | > npm run clean & npm run build 53 | 54 | `build` directory will be created during the build 55 | 56 | #### 5. Starting the application 57 | 58 | Start the application by running the following command: 59 | 60 | > npm start 61 | 62 | The application will be displayed in the browser. 63 | 64 | Resources 65 | --------- 66 | 67 | - [A step-by-step tutorial](http://blog.codeleak.pl/2016/03/quickstart-angular2-with-typescript-and.html) 68 | -------------------------------------------------------------------------------- /bs-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "port": 8000, 3 | "files": [ 4 | "build/**/*.{html,htm,css,js}" 5 | ], 6 | "server": { 7 | "baseDir": "build" 8 | } 9 | } -------------------------------------------------------------------------------- /gulpfile.ts: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const gulp = require("gulp"); 4 | const del = require("del"); 5 | const tsc = require("gulp-typescript"); 6 | const sourcemaps = require('gulp-sourcemaps'); 7 | const tsProject = tsc.createProject("tsconfig.json"); 8 | const tslint = require('gulp-tslint'); 9 | 10 | /** 11 | * Remove build directory. 12 | */ 13 | gulp.task('clean', (cb) => { 14 | return del(["build"], cb); 15 | }); 16 | 17 | /** 18 | * Lint all custom TypeScript files. 19 | */ 20 | gulp.task('tslint', () => { 21 | return gulp.src("src/**/*.ts") 22 | .pipe(tslint({ 23 | formatter: 'prose' 24 | })) 25 | .pipe(tslint.report()); 26 | }); 27 | 28 | /** 29 | * Compile TypeScript sources and create sourcemaps in build directory. 30 | */ 31 | gulp.task("compile", ["tslint"], () => { 32 | let tsResult = gulp.src("src/**/*.ts") 33 | .pipe(sourcemaps.init()) 34 | .pipe(tsProject()); 35 | return tsResult.js 36 | .pipe(sourcemaps.write(".", {sourceRoot: '/src'})) 37 | .pipe(gulp.dest("build")); 38 | }); 39 | 40 | /** 41 | * Copy all resources that are not TypeScript files into build directory. 42 | */ 43 | gulp.task("resources", () => { 44 | return gulp.src(["src/**/*", "!**/*.ts"]) 45 | .pipe(gulp.dest("build")); 46 | }); 47 | 48 | /** 49 | * Copy all required libraries into build directory. 50 | */ 51 | gulp.task("libs", () => { 52 | return gulp.src([ 53 | 'core-js/client/shim.min.js', 54 | 'systemjs/dist/system-polyfills.js', 55 | 'systemjs/dist/system.src.js', 56 | 'reflect-metadata/Reflect.js', 57 | 'rxjs/**/*.js', 58 | 'zone.js/dist/**', 59 | '@angular/**/bundles/**' 60 | ], {cwd: "node_modules/**"}) /* Glob required here. */ 61 | .pipe(gulp.dest("build/lib")); 62 | }); 63 | 64 | /** 65 | * Watch for changes in TypeScript, HTML and CSS files. 66 | */ 67 | gulp.task('watch', function () { 68 | gulp.watch(["src/**/*.ts"], ['compile']).on('change', function (e) { 69 | console.log('TypeScript file ' + e.path + ' has been changed. Compiling.'); 70 | }); 71 | gulp.watch(["src/**/*.html", "src/**/*.css"], ['resources']).on('change', function (e) { 72 | console.log('Resource file ' + e.path + ' has been changed. Updating.'); 73 | }); 74 | }); 75 | 76 | /** 77 | * Build the project. 78 | */ 79 | gulp.task("build", ['compile', 'resources', 'libs'], () => { 80 | console.log("Building the project ..."); 81 | }); -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular2-typescript-gulp", 3 | "version": "1.0.0", 4 | "description": "Angular2 with TypeScript and Gulp QuickStart", 5 | "scripts": { 6 | "clean": "gulp clean", 7 | "compile": "gulp compile", 8 | "build": "gulp build", 9 | "start": "concurrent --kill-others \"gulp watch\" \"lite-server\"", 10 | "postinstall": "typings install" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/kolorobot/angular2-typescript-gulp.git" 15 | }, 16 | "author": "Rafał Borowiec", 17 | "license": "MIT", 18 | "bugs": { 19 | "url": "https://github.com/kolorobot/angular2-typescript-gulp/issues" 20 | }, 21 | "dependencies": { 22 | "@angular/common": "~2.2.4", 23 | "@angular/compiler": "~2.2.4", 24 | "@angular/core": "~2.2.4", 25 | "@angular/forms": "~2.2.4", 26 | "@angular/http": "~2.2.4", 27 | "@angular/platform-browser": "~2.2.4", 28 | "@angular/platform-browser-dynamic": "~2.2.4", 29 | "@angular/router": "~3.2.4", 30 | "@angular/upgrade": "~2.2.4", 31 | 32 | "core-js": "^2.4.1", 33 | "reflect-metadata": "^0.1.3", 34 | "rxjs": "5.0.0-beta.12", 35 | "systemjs": "0.19.27", 36 | "zone.js": "^0.6.23" 37 | }, 38 | "devDependencies": { 39 | "concurrently": "^3.1.0", 40 | "del": "^2.2.0", 41 | "gulp": "^3.9.1", 42 | "gulp-sourcemaps": "^1.9.1", 43 | "gulp-tslint": "^7.0.1", 44 | "gulp-typescript": "^3.1.3", 45 | "lite-server": "^2.2.2", 46 | "tslint": "^4.0.2", 47 | "typescript": "^2.1.4", 48 | "typings": "^2.0.0", 49 | "ts-node": "^1.7.2" 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/app/about/components/about.component.ts: -------------------------------------------------------------------------------- 1 | import {Component} from "@angular/core"; 2 | import {OnInit} from "@angular/core"; 3 | 4 | @Component({ 5 | templateUrl: './app/about/components/about.html' 6 | }) 7 | export class AboutComponent implements OnInit { 8 | 9 | ngOnInit() { 10 | 11 | } 12 | } -------------------------------------------------------------------------------- /src/app/about/components/about.html: -------------------------------------------------------------------------------- 1 |
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
-------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import {Component, OnInit} from "@angular/core"; 2 | 3 | @Component({ 4 | selector: "app", 5 | templateUrl: "./app/app.html" 6 | }) 7 | export class AppComponent implements OnInit { 8 | ngOnInit() { 9 | console.log("Application component initialized ..."); 10 | } 11 | } -------------------------------------------------------------------------------- /src/app/app.html: -------------------------------------------------------------------------------- 1 |