Skip to content

Instantly share code, notes, and snippets.

@thetom88
Last active August 21, 2016 10:05
Show Gist options
  • Save thetom88/36e5f7b95e1ccd824a38b6355e519f99 to your computer and use it in GitHub Desktop.
Save thetom88/36e5f7b95e1ccd824a38b6355e519f99 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)
const proxy = require('proxy-middleware');
import { join } from 'path';
import { argv } from 'yargs';
import { SeedConfig } from './seed.config';
/**
* This class extends the basic seed configuration, allowing for project specific overrides. A few examples can be found
* below.
*/
export class ProjectConfig extends SeedConfig {
PROJECT_TASKS_DIR = join(process.cwd(), this.TOOLS_DIR, 'tasks', 'project');
constructor() {
super();
/* Enable typeless compiler runs (faster) between typed compiler runs. */
// this.TYPED_COMPILE_INTERVAL = 5;
// Add `NPM` third-party libraries to be injected/bundled.
this.NPM_DEPENDENCIES = [
...this.NPM_DEPENDENCIES,
// {src: 'jquery/dist/jquery.min.js', inject: 'libs'},
// {src: 'lodash/lodash.min.js', inject: 'libs'},
];
// Add `local` third-party libraries to be injected/bundled.
this.APP_ASSETS = [
...this.APP_ASSETS,
// {src: `${this.APP_SRC}/your-path-to-lib/libs/jquery-ui.js`, inject: true, vendor: false}
// {src: `${this.CSS_SRC}/path-to-lib/test-lib.css`, inject: true, vendor: false},
];
/* Add to or override NPM module configurations: */
// this.mergeObject(this.PLUGIN_CONFIGS['browser-sync'], { ghostMode: false });
this.PLUGIN_CONFIGS['browser-sync']= {
port: this.PORT,
startPath: this.APP_BASE,
server: {
baseDir: `${this.DIST_DIR}/empty/`,
middleware: [
proxy({
protocol: 'http:',
hostname: 'localhost',
port: 8081,
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
}
}
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment