Skip to content

Instantly share code, notes, and snippets.

@silentHoo
Created May 10, 2016 12:40
Show Gist options
  • Save silentHoo/37c14608a41a430b7fe13cfacd3e8f6c to your computer and use it in GitHub Desktop.
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)
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);
}
}
@thetom88
Copy link

thetom88 commented Aug 21, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment