Skip to content

Commit 8b5a37c

Browse files
committed
fix bundler preview path
1 parent 37e7278 commit 8b5a37c

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

packages/angular/angular.webpack.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -150,24 +150,27 @@ export abstract class AngularWebpack {
150150
return targetPath;
151151
}
152152

153-
async createDevServer(context: DevServerContext, transformers: WebpackConfigTransformer[] = []): Promise<DevServer> {
154-
let rootPath: string;
153+
private getPreviewRootPath(): string {
155154
try {
156-
rootPath = this.workspace?.componentDir(ComponentID.fromString('teambit.angular/angular'), {
155+
const rootPath = this.workspace?.componentDir(ComponentID.fromString('teambit.angular/angular'), {
157156
ignoreScopeAndVersion: true,
158157
ignoreVersion: true
159158
}, { relative: false }) || '';
160-
rootPath = join(rootPath, 'preview');
159+
return join(rootPath, 'preview');
161160
} catch(e) {
162-
rootPath = resolve(require.resolve('@teambit/angular'), '../../preview/');
161+
return resolve(require.resolve('@teambit/angular'), '../../preview/');
163162
}
164-
const tsconfigPath = this.writeTsconfig(context, rootPath);
163+
}
164+
165+
async createDevServer(context: DevServerContext, transformers: WebpackConfigTransformer[] = []): Promise<DevServer> {
166+
const previewRootPath = this.getPreviewRootPath();
167+
const tsconfigPath = this.writeTsconfig(context, previewRootPath);
165168

166169
const defaultConfig: any = await this.getWebpackConfig(
167170
context,
168171
context.entry,
169172
tsconfigPath,
170-
rootPath,
173+
previewRootPath,
171174
this.webpackMain.logger,
172175
WebpackSetup.Serve,
173176
this.webpackServeOptions,
@@ -205,14 +208,14 @@ export abstract class AngularWebpack {
205208

206209
async createBundler(context: BundlerContext, transformers: any[]): Promise<Bundler> {
207210
// TODO(ocombe) find a better way to get the preview root path
208-
const rootPath = resolve(require.resolve('@teambit/angular'), '../../preview/');
209-
const tsconfigPath = this.writeTsconfig(context, rootPath);
211+
const previewRootPath = this.getPreviewRootPath();
212+
const tsconfigPath = this.writeTsconfig(context, previewRootPath);
210213

211214
const defaultConfig: any = await this.getWebpackConfig(
212215
context,
213216
context.targets.map((target: Target) => target.entries).flat(),
214217
tsconfigPath,
215-
rootPath,
218+
previewRootPath,
216219
this.webpackMain.logger,
217220
WebpackSetup.Build,
218221
this.webpackBuildOptions as WebpackConfigWithDevServer,

0 commit comments

Comments
 (0)