├── src ├── app │ ├── app.component.pug │ ├── app.component.scss │ ├── app.component.ts │ ├── app.module.ts │ └── app.component.spec.ts ├── favicon.ico ├── environments │ ├── environment.ts │ └── environment.production.ts ├── index.pug ├── assets │ ├── main.scss │ └── variables.scss ├── tsconfig.app.json ├── tsconfig.spec.json ├── main.ts ├── polyfills.ts └── test.ts ├── .gitignore ├── e2e ├── app.po.ts ├── tsconfig.e2e.json └── app.e2e-spec.ts ├── tsconfig.json ├── protractor.conf.js ├── README.md ├── karma.conf.js ├── package.json ├── tslint.json └── webpack.config.js /src/app/app.component.pug: -------------------------------------------------------------------------------- 1 | h1 {{ title }} 2 | -------------------------------------------------------------------------------- /src/app/app.component.scss: -------------------------------------------------------------------------------- 1 | h1 { 2 | font-size: 48px; 3 | } 4 | -------------------------------------------------------------------------------- /src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Big-Silver/Angular4-Amchart/HEAD/src/favicon.ico -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: false 3 | }; 4 | -------------------------------------------------------------------------------- /src/environments/environment.production.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /src/index.pug: -------------------------------------------------------------------------------- 1 | head 2 | meta(charset='UTF-8') 3 | title Angular 4 Seed 4 | base(href='') 5 | body 6 | app-root Loading... 7 | -------------------------------------------------------------------------------- /src/assets/main.scss: -------------------------------------------------------------------------------- 1 | @import "variables"; 2 | 3 | body { 4 | background-color: $white; 5 | color: $black; 6 | -webkit-font-smoothing: antialiased; 7 | } 8 | -------------------------------------------------------------------------------- /src/assets/variables.scss: -------------------------------------------------------------------------------- 1 | // Colors 2 | $white: #ffffff; 3 | $black: #343840; 4 | $blue: #377ec8; 5 | $teal: #85add6; 6 | $green: #79D18A; 7 | $red: #ED6E62; 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # compiled output 2 | /dist 3 | /tmp 4 | /out-tsc 5 | 6 | # dependencies 7 | /node_modules 8 | 9 | # e2e 10 | /e2e/*.js 11 | /e2e/*.map 12 | 13 | # System Files 14 | .DS_Store 15 | Thumbs.db 16 | -------------------------------------------------------------------------------- /e2e/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, element, by } from 'protractor'; 2 | 3 | export class TestPage { 4 | navigateTo() { 5 | return browser.get('/'); 6 | } 7 | getParagraphText() { 8 | return element(by.css('app-root h1')).getText(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /e2e/tsconfig.e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/e2e", 5 | "module": "commonjs", 6 | "target": "es5", 7 | "types":[ 8 | "jasmine", 9 | "node" 10 | ] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "module": "es2015", 6 | "baseUrl": "", 7 | "types": [] 8 | }, 9 | "exclude": [ 10 | "test.ts", 11 | "**/*.spec.ts" 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-root', 5 | templateUrl: './app.component.pug', 6 | styleUrls: ['./app.component.scss'] 7 | }) 8 | export class AppComponent { 9 | title = 'app works!'; 10 | constructor() {} 11 | } 12 | -------------------------------------------------------------------------------- /src/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../lib/spec", 5 | "module": "es2015", 6 | "target": "es5", 7 | "types": [ 8 | "jasmine", 9 | "node" 10 | ] 11 | }, 12 | "files": [ 13 | "test.ts" 14 | ], 15 | "include": [ 16 | "**/*.spec.ts", 17 | "**/*.d.ts" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /e2e/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { TestPage } from './app.po' 2 | 3 | describe('ngtest App', () => { 4 | let page: TestPage 5 | beforeEach(() => { 6 | page = new TestPage() 7 | }) 8 | it('should display message saying app works', async () => { 9 | await page.navigateTo() 10 | const text = await page.getParagraphText() 11 | expect(text).toEqual('app works!') 12 | }) 13 | }) 14 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | // import scss 2 | import './assets/main.scss' 3 | 4 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 5 | import { enableProdMode } from '@angular/core' 6 | import { AppModule } from './app/app.module'; 7 | import { environment } from 'environments/environment'; 8 | 9 | if (environment.production) { 10 | enableProdMode(); 11 | } 12 | 13 | platformBrowserDynamic().bootstrapModule(AppModule); 14 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "outDir": "./dist/out-tsc", 5 | "baseUrl": "./src", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "skipLibCheck": true, 9 | "moduleResolution": "node", 10 | "emitDecoratorMetadata": true, 11 | "experimentalDecorators": true, 12 | "target": "es5", 13 | "typeRoots": [ 14 | "node_modules/@types" 15 | ], 16 | "lib": [ 17 | "es2016", 18 | "dom" 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { NgModule } from '@angular/core'; 3 | import { FormsModule } from '@angular/forms'; 4 | import { HttpModule } from '@angular/http'; 5 | 6 | import { AppComponent } from './app.component'; 7 | 8 | @NgModule({ 9 | declarations: [ 10 | AppComponent 11 | ], 12 | imports: [ 13 | BrowserModule, 14 | FormsModule, 15 | HttpModule 16 | ], 17 | bootstrap: [AppComponent] 18 | }) 19 | export class AppModule { } 20 | -------------------------------------------------------------------------------- /src/polyfills.ts: -------------------------------------------------------------------------------- 1 | // Polyfills 2 | // 3 | // IE9 - IE11 support polyfills 4 | // import 'core-js/es6/symbol' 5 | // import 'core-js/es6/object' 6 | // import 'core-js/es6/function' 7 | // import 'core-js/es6/parse-int' 8 | // import 'core-js/es6/parse-float' 9 | // import 'core-js/es6/number' 10 | // import 'core-js/es6/math' 11 | // import 'core-js/es6/string' 12 | // import 'core-js/es6/date' 13 | // import 'core-js/es6/array' 14 | // import 'core-js/es6/regexp' 15 | // import 'core-js/es6/map' 16 | // import 'core-js/es6/set' 17 | 18 | import 'core-js/es6/reflect' 19 | import 'core-js/es7/reflect' 20 | 21 | import 'zone.js/dist/zone' 22 | -------------------------------------------------------------------------------- /protractor.conf.js: -------------------------------------------------------------------------------- 1 | const { SpecReporter } = require('jasmine-spec-reporter'); 2 | const { register } = require('ts-node') 3 | 4 | exports.config = { 5 | allScriptsTimeout: 11000, 6 | specs: [ 7 | './e2e/**/*.e2e-spec.ts' 8 | ], 9 | capabilities: { 10 | 'browserName': 'chrome' 11 | }, 12 | directConnect: true, 13 | baseUrl: 'http://localhost:8080/', 14 | framework: 'jasmine', 15 | jasmineNodeOpts: { 16 | showColors: true, 17 | defaultTimeoutInterval: 30000, 18 | print () {} 19 | }, 20 | beforeLaunch () { 21 | register({ 22 | project: 'e2e/tsconfig.e2e.json' 23 | }); 24 | }, 25 | onPrepare() { 26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # `Angular 4 - Amchart` — starter project for Angular 4 apps 2 | 3 | This project is an application skeleton for a [Angular4][angular4] web app. You can use it 4 | to quickly bootstrap your angular4 projects and dev environment for these projects. 5 | 6 | The project is preconfigured to install the Angular 4 and a bunch of development and testing tools including linter which follows the angular style guide found in https://angular.io/styleguide. 7 | 8 | ### Usage 9 | 10 | - Clone or fork this repository 11 | ``` 12 | git clone https://github.com/willyelm/angular4-seed.git 13 | cd angular4-seed 14 | ``` 15 | 16 | - install dependencies 17 | ``` 18 | npm install 19 | ``` 20 | 21 | - fire up dev server 22 | ``` 23 | npm start 24 | ``` 25 | open browser to [`http://localhost:8080`](http://localhost:8080) 26 | 27 | ### Running Unit Tests 28 | ``` 29 | npm test 30 | ``` 31 | ### Running E2E Tests 32 | ``` 33 | npm run webdriver 34 | npm run e2e 35 | ``` 36 | 37 | 38 | [angular4]: https://angular.io/ 39 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | const webpackConfig = require('./webpack.config') 2 | 3 | module.exports = function (config) { 4 | config.set({ 5 | basePath: '', 6 | frameworks: ['jasmine'], 7 | plugins: [ 8 | require('karma-jasmine'), 9 | require('karma-chrome-launcher'), 10 | require('karma-webpack'), 11 | require('karma-sourcemap-loader'), 12 | require('karma-jasmine-html-reporter') 13 | ], 14 | client:{ 15 | clearContext: false 16 | }, 17 | files: [ 18 | { pattern: './src/test.ts', watched: false } 19 | ], 20 | preprocessors: { 21 | './src/test.ts': [ 'webpack', 'sourcemap' ] 22 | }, 23 | mime: { 24 | 'text/x-typescript': ['ts','tsx'] 25 | }, 26 | webpack: webpackConfig, 27 | webpackMiddleware: { 28 | stats: webpackConfig.stats 29 | }, 30 | reporters: ['progress', 'kjhtml'], 31 | colors: true, 32 | logLevel: config.LOG_INFO, 33 | autoWatch: true, 34 | browsers: ['Chrome'], 35 | singleRun: false 36 | }); 37 | }; 38 | -------------------------------------------------------------------------------- /src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | import { AppComponent } from './app.component'; 3 | 4 | describe('AppComponent', () => { 5 | beforeEach(() => { 6 | TestBed.configureTestingModule({ 7 | declarations: [ 8 | AppComponent 9 | ] 10 | }).compileComponents(); 11 | }); 12 | 13 | it('should create the app', () => { 14 | const fixture = TestBed.createComponent(AppComponent); 15 | const app = fixture.debugElement.componentInstance; 16 | expect(app).toBeTruthy(); 17 | }); 18 | 19 | it(`should have as title 'app works!'`, () => { 20 | const fixture = TestBed.createComponent(AppComponent); 21 | const app = fixture.debugElement.componentInstance; 22 | expect(app.title).toEqual('app works!'); 23 | }); 24 | 25 | it('should render title in a h1 tag', () => { 26 | const fixture = TestBed.createComponent(AppComponent); 27 | fixture.detectChanges(); 28 | const compiled = fixture.debugElement.nativeElement; 29 | expect(compiled.querySelector('h1').textContent).toContain('app works!'); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /src/test.ts: -------------------------------------------------------------------------------- 1 | import 'core-js/es7/reflect' 2 | import 'zone.js/dist/zone' 3 | import 'zone.js/dist/long-stack-trace-zone'; 4 | import 'zone.js/dist/proxy.js'; 5 | import 'zone.js/dist/sync-test'; 6 | import 'zone.js/dist/jasmine-patch'; 7 | import 'zone.js/dist/async-test'; 8 | import 'zone.js/dist/fake-async-test'; 9 | import { getTestBed } from '@angular/core/testing'; 10 | import { 11 | BrowserDynamicTestingModule, 12 | platformBrowserDynamicTesting 13 | } from '@angular/platform-browser-dynamic/testing'; 14 | 15 | // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any. 16 | declare var __karma__: any; 17 | declare var require: any; 18 | 19 | __karma__.loaded = () => {}; 20 | 21 | // First, initialize the Angular testing environment. 22 | getTestBed().initTestEnvironment( 23 | BrowserDynamicTestingModule, 24 | platformBrowserDynamicTesting() 25 | ); 26 | // Then we find all the tests. 27 | const context = require.context('./', true, /\.spec\.ts$/); 28 | // And load the modules. 29 | context.keys().map(context); 30 | // Finally, start Karma to run the tests. 31 | __karma__.start(); 32 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular4-seed", 3 | "license": "MIT", 4 | "author": "Williams Medina ", 5 | "scripts": { 6 | "start": "NODE_ENV=development webpack-dev-server", 7 | "lint": "tslint --project tsconfig.json src/**/*.ts", 8 | "test": "NODE_ENV=testing karma start --single-run", 9 | "build": "NODE_ENV=production webpack", 10 | "prebuild": "npm run lint && npm run test", 11 | "webdriver": "webdriver-manager update", 12 | "e2e": "NODE_ENV=testing protractor" 13 | }, 14 | "dependencies": { 15 | "@angular/animations": "^5.0.0", 16 | "@angular/common": "^5.0.0", 17 | "@angular/compiler": "^5.0.0", 18 | "@angular/core": "^5.0.0", 19 | "@angular/forms": "^5.0.0", 20 | "@angular/http": "^5.0.0", 21 | "@angular/platform-browser": "^5.0.0", 22 | "@angular/platform-browser-dynamic": "^5.0.0", 23 | "@angular/router": "^5.0.0", 24 | "core-js": "^2.5.1", 25 | "rxjs": "^5.5.2", 26 | "zone.js": "^0.8.18" 27 | }, 28 | "devDependencies": { 29 | "@angular/cli": "^1.5.0", 30 | "@angular/compiler-cli": "^5.0.0", 31 | "@angular/language-service": "^5.0.0", 32 | "@ngtools/webpack": "^1.8.0-rc.8", 33 | "@types/jasmine": "^2.6.2", 34 | "@types/node": "^7.0.46", 35 | "codelyzer": "^4.0.0", 36 | "copy-webpack-plugin": "^4.2.0", 37 | "css-loader": "^0.28.7", 38 | "extract-text-webpack-plugin": "^3.0.2", 39 | "file-loader": "^0.11.2", 40 | "html-loader": "^0.4.5", 41 | "html-webpack-plugin": "^2.30.1", 42 | "jasmine-core": "^2.8.0", 43 | "jasmine-spec-reporter": "^4.2.1", 44 | "karma": "^1.7.1", 45 | "karma-chrome-launcher": "^2.2.0", 46 | "karma-jasmine": "^1.1.0", 47 | "karma-jasmine-html-reporter": "^0.2.2", 48 | "karma-sourcemap-loader": "^0.3.7", 49 | "karma-webpack": "^2.0.5", 50 | "node-sass": "^4.5.3", 51 | "protractor": "^5.2.0", 52 | "pug-html-loader": "^1.1.5", 53 | "raw-loader": "^0.5.1", 54 | "sass-loader": "^6.0.6", 55 | "style-loader": "^0.18.2", 56 | "to-string-loader": "^1.1.5", 57 | "ts-node": "^3.3.0", 58 | "tslint": "^5.3.2", 59 | "typescript": "^2.4.2", 60 | "url-loader": "^0.5.9", 61 | "webpack": "^3.8.1", 62 | "webpack-dev-server": "^2.9.4", 63 | "webpack-merge": "^4.1.1" 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rulesDirectory": [ 3 | "node_modules/codelyzer" 4 | ], 5 | "rules": { 6 | "directive-selector": [true, "attribute", ["app"], "camelCase"], 7 | "component-selector": [true, "element", ["app"], "kebab-case"], 8 | 9 | "use-input-property-decorator": true, 10 | "use-output-property-decorator": true, 11 | "use-host-property-decorator": true, 12 | "no-attribute-parameter-decorator": true, 13 | "no-input-rename": true, 14 | "no-output-rename": true, 15 | 16 | "no-forward-ref": true, 17 | "use-life-cycle-interface": true, 18 | "use-pipe-transform-interface": true, 19 | 20 | "component-class-suffix": [true, "Component"], 21 | "directive-class-suffix": [true, "Directive"], 22 | "no-access-missing-member": true, 23 | "templates-use-public": true, 24 | "invoke-injectable": true, 25 | 26 | "arrow-return-shorthand": true, 27 | "callable-types": true, 28 | "class-name": true, 29 | "comment-format": [true, "check-space"], 30 | "curly": true, 31 | "eofline": true, 32 | "forin": true, 33 | "import-blacklist": [true, "rxjs"], 34 | "import-spacing": true, 35 | "indent": [true,"spaces"], 36 | "interface-over-type-literal": true, 37 | "label-position": true, 38 | "max-line-length": [true, 100], 39 | "member-access": false, 40 | "member-ordering": [true, "static-before-instance", "variables-before-functions"], 41 | "no-arg": true, 42 | "no-bitwise": true, 43 | "no-console": [true, "debug", "info", "time", "timeEnd", "trace"], 44 | "no-construct": true, 45 | "no-debugger": true, 46 | "no-duplicate-super": true, 47 | "no-empty": false, 48 | "no-empty-interface": true, 49 | "no-eval": true, 50 | "no-inferrable-types": [true, "ignore-params"], 51 | "no-misused-new": true, 52 | "no-non-null-assertion": true, 53 | "no-shadowed-variable": true, 54 | "no-string-literal": false, 55 | "no-string-throw": true, 56 | "no-switch-case-fall-through": true, 57 | "no-trailing-whitespace": true, 58 | "no-unnecessary-initializer": true, 59 | "no-unused-expression": true, 60 | "no-use-before-declare": true, 61 | "no-var-keyword": true, 62 | "object-literal-sort-keys": false, 63 | "one-line": [true, "check-open-brace", "check-catch", "check-else" ,"check-whitespace"], 64 | "prefer-const": true, 65 | "quotemark": [true,"single"], 66 | "radix": true, 67 | "semicolon": ["always"], 68 | "triple-equals": [true, "allow-null-check"], 69 | "typedef-whitespace": [ 70 | true, { 71 | "call-signature": "nospace", 72 | "index-signature": "nospace", 73 | "parameter": "nospace", 74 | "property-declaration": "nospace", 75 | "variable-declaration": "nospace" 76 | } 77 | ], 78 | "typeof-compare": true, 79 | "unified-signatures": true, 80 | "variable-name": false, 81 | "whitespace": [true, "check-branch", "check-decl", "check-operator", "check-separator", "check-type"] 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | const webpackMerge = require('webpack-merge') 3 | const ExtractTextPlugin = require('extract-text-webpack-plugin') 4 | const HtmlPlugin = require('html-webpack-plugin') 5 | const { DefinePlugin, ProgressPlugin, optimize, ContextReplacementPlugin, NormalModuleReplacementPlugin } = require('webpack') 6 | const { AngularCompilerPlugin } = require('@ngtools/webpack') 7 | 8 | const TEST_ASSETS = /assets[\/\\].*\.scss$/; 9 | const OUTPUT_PATH = path.resolve(__dirname, 'dist') 10 | const SOURCE_PATH = path.resolve(__dirname, 'src') 11 | const STATS = { 12 | colors: true, 13 | hash: true, 14 | timings: true, 15 | chunks: true, 16 | chunkModules: false, 17 | children: false, 18 | modules: false, 19 | reasons: false, 20 | warnings: true, 21 | assets: false, 22 | version: false 23 | } 24 | const ENV = process.env.ENV = process.env.NODE_ENV = 'development'; 25 | function getAotOptions () { 26 | let options = { 27 | tsConfigPath: './src/tsconfig.app.json' 28 | } 29 | switch (process.env.NODE_ENV) { 30 | case 'testing': 31 | options.skipCodeGeneration = true 32 | options.tsConfigPath = './src/tsconfig.spec.json' 33 | break 34 | case 'development': 35 | options.skipCodeGeneration = true 36 | options.mainPath = path.resolve(__dirname, SOURCE_PATH, 'main.ts') 37 | break 38 | case 'production': 39 | options.mainPath = path.resolve(__dirname, SOURCE_PATH, 'main.ts') 40 | break 41 | } 42 | return options; 43 | } 44 | 45 | function chunksSortMethod (a, b) { 46 | let priority = ['main', 'vendor', 'polyfills'] 47 | return priority.indexOf(b.names[0]) 48 | } 49 | 50 | const webpackConfig = { 51 | context: __dirname, 52 | resolve: { 53 | extensions: ['.ts', '.js'], 54 | modules: [ 55 | path.resolve(__dirname, 'node_modules'), 56 | SOURCE_PATH 57 | ], 58 | symlinks: true 59 | }, 60 | output: { 61 | path: OUTPUT_PATH, 62 | publicPath: '', 63 | filename: '[name].bundle.js' 64 | }, 65 | plugins: [ 66 | new AngularCompilerPlugin(getAotOptions()), 67 | new ProgressPlugin(), 68 | new ExtractTextPlugin('main.css'), 69 | new DefinePlugin({ 70 | 'process.env': { 71 | 'NODE_ENV': JSON.stringify(process.env.NODE_ENV) 72 | } 73 | }), 74 | new optimize.CommonsChunkPlugin({ 75 | name: 'vendor', 76 | chunks: ['main'], 77 | minChunks(module) { 78 | return /node_modules/.test(module.resource) 79 | } 80 | }), 81 | new optimize.OccurrenceOrderPlugin(true), 82 | new ContextReplacementPlugin(/angular(\\|\/)core(\\|\/)src(\\|\/)linker/, 83 | SOURCE_PATH, { 84 | // your Angular Async Route paths relative to this root directory 85 | }) 86 | ], 87 | module: { 88 | rules: [ 89 | // { test: /\.scss$/, exclude: TEST_ASSETS, loaders: ['raw-loader', 'sass-loader'] }, 90 | { test: TEST_ASSETS, use: ExtractTextPlugin.extract({ 91 | fallback: 'style-loader', 92 | use: ['css-loader', 'sass-loader'] 93 | })}, 94 | // load scss from app as raw css strings 95 | { test: /\.scss$/, exclude: TEST_ASSETS, loaders: ['to-string-loader', 'css-loader', 'sass-loader'] }, 96 | { test: /\.css$/, loader: 'raw-loader' }, 97 | { test: /\.ts$/, loader: '@ngtools/webpack' }, 98 | { test: /\.jpg$/, loader: "file-loader" }, 99 | { test: /\.png$/, loader: "url-loader?mimetype=image/png" }, 100 | { test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/, loader: 'url-loader?limit=10000' }, 101 | { test: /\.html$/, loader: 'raw-loader' }, 102 | { test: /\.pug$/, loaders: [ 103 | 'html-loader', { 104 | loader: 'pug-html-loader', 105 | options: { 106 | doctype: 'html' 107 | } 108 | } 109 | ]} 110 | ] 111 | }, 112 | stats: STATS 113 | }; 114 | 115 | const webpackEnv = { 116 | // Production 117 | production: { 118 | // devtool: 'source-map', 119 | entry: { 120 | polyfills: path.join(SOURCE_PATH, 'polyfills.ts'), 121 | main: path.join(SOURCE_PATH, 'main.ts') 122 | }, 123 | plugins: [ 124 | new HtmlPlugin({ 125 | filetype: 'pug', 126 | template: path.join(SOURCE_PATH, 'index.pug'), 127 | chunksSortMode: chunksSortMethod, 128 | hash: true 129 | }), 130 | new NormalModuleReplacementPlugin( 131 | /src\/environments\/environment.ts/, 132 | 'environment.production.ts' 133 | ), 134 | new optimize.UglifyJsPlugin({ 135 | beautify: false, 136 | output: { 137 | comments: false 138 | }, 139 | mangle: { 140 | screw_ie8: true 141 | }, 142 | compress: { 143 | screw_ie8: true, 144 | warnings: false, 145 | conditionals: true, 146 | unused: true, 147 | comparisons: true, 148 | sequences: true, 149 | dead_code: true, 150 | evaluate: true, 151 | if_return: true, 152 | join_vars: true, 153 | negate_iife: false 154 | } 155 | }) 156 | ] 157 | }, 158 | // Development 159 | development: { 160 | devtool: 'inline-source-map', 161 | entry: { 162 | polyfills: path.join(SOURCE_PATH, 'polyfills.ts'), 163 | main: path.join(SOURCE_PATH, 'main.ts') 164 | }, 165 | plugins: [ 166 | new HtmlPlugin({ 167 | filetype: 'pug', 168 | template: path.join(SOURCE_PATH, 'index.pug'), 169 | chunksSortMode: chunksSortMethod, 170 | hash: true 171 | }) 172 | ], 173 | devServer: { 174 | contentBase: OUTPUT_PATH, 175 | historyApiFallback: true, 176 | stats: STATS 177 | // headers: { 178 | // 'Access-Control-Allow-Origin': '*', 179 | // 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS', 180 | // 'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization', 181 | // 'Access-Control-Allow-Credentials': 'true', 182 | // 'Content-Security-Policy': 'default-src \'self\' \'unsafe-inline\'' 183 | // } 184 | } 185 | }, 186 | // Testing 187 | testing: {} 188 | } 189 | 190 | module.exports = webpackMerge(webpackConfig, webpackEnv[process.env.NODE_ENV]); 191 | --------------------------------------------------------------------------------