Created
May 10, 2016 12:40
-
-
Save silentHoo/37c14608a41a430b7fe13cfacd3e8f6c to your computer and use it in GitHub Desktop.
Project specific browsersync configuration with reverse proxy (https://github.com/mgechev/angular2-seed/blob/master/tools/config/project.config.ts)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const proxy = require('proxy-middleware'); | |
import {join} from 'path'; | |
import {SeedConfig} from './seed.config'; | |
import {InjectableDependency} from './seed.config.interfaces'; | |
export class ProjectConfig extends SeedConfig { | |
PROJECT_TASKS_DIR = join(process.cwd(), this.TOOLS_DIR, 'tasks', 'project'); | |
constructor() { | |
super(); | |
// this.APP_TITLE = 'Put name of your app here'; | |
// add reverse proxy here | |
this.BROWSER_SYNC_CONFIG = { | |
port: this.PORT, | |
startPath: this.APP_BASE, | |
server: { | |
baseDir: `${this.DIST_DIR}/empty/`, | |
middleware: [ | |
proxy({ | |
protocol: 'http:', | |
hostname: 'localhost', | |
port: 8080, | |
pathname: '/api', | |
route: '/api' | |
}), | |
require('connect-history-api-fallback')({index: `${this.APP_BASE}index.html`}) | |
], | |
routes: { | |
[`${this.APP_BASE}${this.APP_DEST}`]: this.APP_DEST, | |
[`${this.APP_BASE}node_modules`]: 'node_modules', | |
[`${this.APP_BASE.replace(/\/$/,'')}`]: this.APP_DEST | |
} | |
} | |
}; | |
let additional_deps: InjectableDependency[] = [ | |
// {src: 'jquery/dist/jquery.min.js', inject: 'libs'}, | |
// {src: 'lodash/lodash.min.js', inject: 'libs'}, | |
]; | |
const seedDependencies = this.NPM_DEPENDENCIES; | |
this.NPM_DEPENDENCIES = seedDependencies.concat(additional_deps); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does this work with the most recent version of the seed too? I can't get it working.. I get the following error during compilation:
Property 'BROWSER_SYNC_CONFIG' does not exist on type 'ProjectConfig'.
For me it seems that browser sync config are now managed in a different way as shown here:
https://github.com/mgechev/angular2-seed/blob/master/tools/config/seed.config.ts#L421