Skip to content

Commit

Permalink
fix(angular): disable unnesasary webpack stuff if we use angular-cli …
Browse files Browse the repository at this point in the history
…>= 12
  • Loading branch information
ThibaudAV committed Jan 6, 2022
1 parent d3adeb8 commit d2eafa7
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions app/angular/src/server/framework-preset-angular.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
import path from 'path';
import semver from '@storybook/semver';
import { ContextReplacementPlugin, Configuration } from 'webpack';
import autoprefixer from 'autoprefixer';
import getTsLoaderOptions from './ts_config';
import createForkTsCheckerInstance from './create-fork-ts-checker-plugin';

export function webpack(
export async function webpack(
config: Configuration,
{ configDir }: { configDir: string }
): Configuration {
): Promise<Configuration> {
try {
// Disable all this webpack stuff if we use angular-cli >= 12
// Angular cli is in charge of doing all the necessary for angular. If there is any additional configuration to add, it must be done in the preset angular-cli versioned.
const angularCliVersion = await import('@angular/cli').then((m) =>
semver.coerce(m.VERSION.full)
);
if (semver.satisfies(angularCliVersion, '>=12.0.0')) {
return config;
}
} catch (error) {
// do nothing, continue
}

const tsLoaderOptions = getTsLoaderOptions(configDir);
return {
...config,
Expand Down

0 comments on commit d2eafa7

Please sign in to comment.