11import { Schema as BrowserBuilderSchema } from '@angular-devkit/build-angular/src/browser/schema' ;
22import { Bundler , BundlerContext , DevServer , DevServerContext , Target } from '@teambit/bundler' ;
33import { CACHE_ROOT } from '@teambit/legacy/dist/constants' ;
4+ import { ComponentID } from '@teambit/component' ;
45import { PkgMain } from '@teambit/pkg' ;
56import { pathNormalizeToLinux } from '@teambit/legacy/dist/utils' ;
67import { Logger } from '@teambit/logger' ;
@@ -21,8 +22,7 @@ import { existsSync, mkdirSync, writeFileSync } from 'fs-extra';
2122import objectHash from 'object-hash' ;
2223import { join , posix , resolve } from 'path' ;
2324import { readConfigFile , sys } from 'typescript' ;
24- import webpack , { Configuration } from 'webpack' ;
25- import WsDevServer from 'webpack-dev-server' ;
25+ import { Configuration } from 'webpack' ;
2626
2727export enum WebpackSetup {
2828 Serve = 'serve' ,
@@ -152,8 +152,16 @@ export abstract class AngularWebpack {
152152 }
153153
154154 async createDevServer ( context : DevServerContext , transformers : WebpackConfigTransformer [ ] = [ ] ) : Promise < DevServer > {
155- // TODO(ocombe) find a better way to get the preview root path
156- const rootPath = resolve ( require . resolve ( '@teambit/angular' ) , '../../preview/' ) ;
155+ let rootPath : string ;
156+ try {
157+ rootPath = this . workspace ?. componentDir ( ComponentID . fromString ( 'teambit.angular/angular' ) , {
158+ ignoreScopeAndVersion : true ,
159+ ignoreVersion : true
160+ } , { relative : false } ) || '' ;
161+ rootPath = join ( rootPath , 'preview' ) ;
162+ } catch ( e ) {
163+ rootPath = resolve ( require . resolve ( '@teambit/angular' ) , '../../preview/' ) ;
164+ }
157165 const tsconfigPath = this . writeTsconfig ( context , rootPath ) ;
158166
159167 const defaultConfig : any = await this . getWebpackConfig (
0 commit comments