Skip to content

Commit

Permalink
add ng2-webpack-config
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksandr Telnov committed Sep 15, 2016
1 parent 0e7e397 commit cdc76cc
Show file tree
Hide file tree
Showing 29 changed files with 306 additions and 429 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ npm-debug.log

# WebStorm
.idea
.vscode

# ignore build and dist for now
/bundles
Expand All @@ -19,6 +20,7 @@ npm-debug.log
# ignore incline compiling
/demo/**/*.js
/demo/**/*.d.ts
!/demo/custom-typings.d.ts
/demo/**/*.js.map
/components/**/*.js
/components/**/*.d.ts
Expand Down
29 changes: 29 additions & 0 deletions .ng2-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use strict';
var pkg = require('./package.json');

module.exports = {
// metadata
title: pkg.description,
baseUrl: '/',
// root folder name
src: 'demo',
dist: 'demo-build',
htmlIndexes: ['index.html'],
// karma bundle src
spec: './spec-bundle.js',
// webpack entry
entry: {
polyfills: './demo/polyfills.ts',
vendor: './demo/vendor.ts',
main: './demo/index.ts'
},
commonChunks: {
name: ['polyfills', 'vendor'].reverse()
},
// webpack alias
alias: {},
copy: [
{from: 'demo/favicon.ico', to: 'favicon.ico'},
{from: 'demo/assets', to: 'assets'}
]
};
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ language: node_js
node_js:
- "6"

before_install: npm i -g npm@latest

script:
- npm run flow.install:typings
- npm test

after_success:
- ./node_modules/.bin/codecov
- ./node_modules/.bin/codecov -f coverage/coverage-final.json

addons:
# sauce labs tunel connector (read more https://docs.travis-ci.com/user/sauce-connect/ )
Expand Down
2 changes: 1 addition & 1 deletion components/file-upload/file-drop.directive.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component} from '@angular/core';
import { Component } from '@angular/core';
import { inject, ComponentFixture, TestBed } from '@angular/core/testing';

import { FileUploader } from './file-uploader.class';
Expand Down
16 changes: 9 additions & 7 deletions components/file-upload/file-drop.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export class FileDropDirective {
@Output() public onFileDrop:EventEmitter<File[]> = new EventEmitter<File[]>();

private element:ElementRef;

public constructor(element:ElementRef) {
this.element = element;
}
Expand Down Expand Up @@ -80,12 +81,13 @@ export class FileDropDirective {
return false;
}
}
/*
_addOverClass(item:any):any {
item.addOverClass();
}

_removeOverClass(item:any):any {
item.removeOverClass();
}*/
/*
_addOverClass(item:any):any {
item.addOverClass();
}
_removeOverClass(item:any):any {
item.removeOverClass();
}*/
}
12 changes: 6 additions & 6 deletions components/file-upload/file-item.class.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {FileLikeObject} from './file-like-object.class';
import {FileUploader, ParsedResponseHeaders, FileUploaderOptions} from './file-uploader.class';
import { FileLikeObject } from './file-like-object.class';
import { FileUploader, ParsedResponseHeaders, FileUploaderOptions } from './file-uploader.class';

export class FileItem {
public file:FileLikeObject;
Expand Down Expand Up @@ -67,19 +67,19 @@ export class FileItem {
}

public onSuccess(response:string, status:number, headers:ParsedResponseHeaders):any {
return {response,status,headers};
return {response, status, headers};
}

public onError(response:string, status:number, headers:ParsedResponseHeaders):any {
return {response,status,headers};
return {response, status, headers};
}

public onCancel(response:string, status:number, headers:ParsedResponseHeaders):any {
return {response,status,headers};
return {response, status, headers};
}

public onComplete(response:string, status:number, headers:ParsedResponseHeaders):any {
return {response,status,headers};
return {response, status, headers};
}

public _onBeforeUpload():void {
Expand Down
2 changes: 1 addition & 1 deletion components/file-upload/file-like-object.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class FileLikeObject {
this.name = path.slice(path.lastIndexOf('/') + path.lastIndexOf('\\') + 2);
}

public _createFromObject(object:{size: number, type: string, name: string}):void {
public _createFromObject(object:{size:number, type:string, name:string}):void {
// this.lastModifiedDate = copy(object.lastModifiedDate);
this.size = object.size;
this.type = object.type;
Expand Down
3 changes: 2 additions & 1 deletion components/file-upload/file-select.directive.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Directive, ElementRef, Input, HostListener } from '@angular/core';

import {FileUploader} from './file-uploader.class';
import { FileUploader } from './file-uploader.class';

// todo: filters

Expand All @@ -9,6 +9,7 @@ export class FileSelectDirective {
@Input() public uploader:FileUploader;

private element:ElementRef;

public constructor(element:ElementRef) {
this.element = element;
}
Expand Down
6 changes: 3 additions & 3 deletions components/file-upload/file-upload.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { FileDropDirective } from './file-drop.directive';
import { FileSelectDirective } from './file-select.directive';

@NgModule({
imports: [CommonModule],
declarations: [FileDropDirective, FileSelectDirective],
exports: [FileDropDirective, FileSelectDirective]
imports: [CommonModule],
declarations: [FileDropDirective, FileSelectDirective],
exports: [FileDropDirective, FileSelectDirective]
})
export class FileUploadModule {
}
16 changes: 8 additions & 8 deletions components/file-upload/file-uploader.class.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {FileLikeObject} from './file-like-object.class';
import {FileItem} from './file-item.class';
import {FileType} from './file-type.class';
import { FileLikeObject } from './file-like-object.class';
import { FileItem } from './file-item.class';
import { FileType } from './file-type.class';

function isFile(value:any):boolean {
return (File && value instanceof File);
Expand Down Expand Up @@ -295,13 +295,13 @@ export class FileUploader {
if (typeof item._file.size !== 'number') {
throw new TypeError('The file specified is no longer valid');
}
if(!this.options.disableMultipart) {
sendable = new FormData();
this._onBuildItemForm(item, sendable);
if (!this.options.disableMultipart) {
sendable = new FormData();
this._onBuildItemForm(item, sendable);

sendable.append(item.alias, item._file, item.file.name);
sendable.append(item.alias, item._file, item.file.name);
} else {
sendable = item._file;
sendable = item._file;
}

xhr.upload.onprogress = (event:any) => {
Expand Down
2 changes: 1 addition & 1 deletion components/file-upload/readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### Usage
```typescript
import {FileSelectDirective, FileDropDirective, FileUploader} from 'ng2-file-upload/ng2-file-upload';
import { FileSelectDirective, FileDropDirective, FileUploader } from 'ng2-file-upload/ng2-file-upload';
```

### Annotations
Expand Down
2 changes: 1 addition & 1 deletion demo/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component} from '@angular/core';
import { Component } from '@angular/core';

let gettingStarted = require('./getting-started.md');

Expand Down
2 changes: 1 addition & 1 deletion demo/components/file-upload-section.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component} from '@angular/core';
import { Component } from '@angular/core';

let doc = require('../../components/file-upload/readme.md');

Expand Down
4 changes: 2 additions & 2 deletions demo/components/file-upload/zs-file-demo/demo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Component, ElementRef, Renderer, Input, HostListener, HostBinding, OnInit} from '@angular/core';
import {FileUploader, FileUploaderOptions} from '../../../../ng2-file-upload';
import { Component, ElementRef, Renderer, Input, HostListener, HostBinding, OnInit } from '@angular/core';
import { FileUploader, FileUploaderOptions } from '../../../../ng2-file-upload';

@Component({
selector: 'demo-file-upload',
Expand Down
1 change: 1 addition & 0 deletions demo/custom-typings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare const ENV:string;
6 changes: 3 additions & 3 deletions demo/ng2-file-upload-demo.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { FileUploadSectionComponent } from './components/file-upload-section';
import { SimpleDemoComponent } from './components/file-upload/simple-demo';

@NgModule({
imports: [BrowserModule, CommonModule, FileUploadModule, Ng2BootstrapModule, FormsModule],
declarations: [DemoComponent, FileUploadSectionComponent, SimpleDemoComponent],
bootstrap: [DemoComponent]
imports: [BrowserModule, CommonModule, FileUploadModule, Ng2BootstrapModule, FormsModule],
declarations: [DemoComponent, FileUploadSectionComponent, SimpleDemoComponent],
bootstrap: [DemoComponent]
})
export class NgFileUploadDemo {
}
28 changes: 28 additions & 0 deletions demo/polyfills.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Polyfills
// (these modules are what are in 'angular2/bundles/angular2-polyfills' so don't use that here)

// import 'ie-shim'; // Internet Explorer
// import 'es6-shim';
// import 'es6-promise';
// import 'es7-reflect-metadata';

// Prefer CoreJS over the polyfills above
import 'core-js/es6';
import 'core-js/es7/reflect';
require('zone.js/dist/zone');
require('reflect-metadata');

// Typescript emit helpers polyfill
import 'ts-helpers';

if ('production' === ENV) {
// Production

} else {
// Development

(Error as any).stackTraceLimit = Infinity;

require('zone.js/dist/long-stack-trace-zone');

}
23 changes: 23 additions & 0 deletions demo/vendor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// For vendors for example jQuery, Lodash, angular2-jwt just import them here unless you plan on
// chunking vendors files for async loading. You would need to import the async loaded vendors
// at the entry point of the async loaded file. Also see custom-typings.d.ts as you also need to
// run `typings install x` where `x` is your module

// Angular 2
import '@angular/common';
import '@angular/core';
import '@angular/forms';
import '@angular/platform-browser';
import '@angular/platform-browser-dynamic';

// RxJS
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/mergeMap';

if ('production' === ENV) {
// Production

} else {
// Development

}
21 changes: 12 additions & 9 deletions gulp-tasks/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@

const gulp = require('gulp');
const tslint = require('gulp-tslint');
const paths = gulp.paths;
const gitignore = require('gitignore-to-glob')();

gitignore.push('**/*.ts');

gulp.task('tslint', () =>
gulp
.src(paths.tssrc)
.pipe(tslint())
.pipe(tslint.report('prose', {
emitError: true,
summarizeFailureOutput: true,
reportLimit: 50
}))
gulp
.src(gitignore)
.pipe(tslint({
formatter: 'verbose',
emitError: true,
summarizeFailureOutput: true,
reportLimit: 50
}))
.pipe(tslint.report())
);

gulp.task('lint', ['tslint']);
9 changes: 0 additions & 9 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@

const gulp = require('gulp');

gulp.paths = {
tssrc: [
'**/*.ts',
'!**/*.d.ts',
'!node_modules/**/*',
'!bundles/**/*',
'!typings/**/*']
};

require('require-dir')('./gulp-tasks');

gulp.task('default', () => {
Expand Down
Loading

0 comments on commit cdc76cc

Please sign in to comment.