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 dbc3208
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions app/angular/src/server/framework-preset-angular.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
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 {
{ configDir, angularBuilderContext }: { configDir: string; angularBuilderContext: any }
): 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.2.x') && angularBuilderContext) ||
semver.satisfies(angularCliVersion, '>=13.0.0')
) {
return config;
}
} catch (error) {
// do nothing, continue
}

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

0 comments on commit dbc3208

Please sign in to comment.