Skip to content

Commit

Permalink
Merge pull request #23064 from storybookjs/norberyt/fix-angular-16-1
Browse files Browse the repository at this point in the history
Bug: Fix for angular 16.1 compatibility
(cherry picked from commit 4f0c895)
  • Loading branch information
ndelangen authored and github-actions[bot] committed Jun 14, 2023
1 parent a8752ee commit e16d8e1
Showing 1 changed file with 37 additions and 6 deletions.
43 changes: 37 additions & 6 deletions code/frameworks/angular/src/server/angular-cli-webpack.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,48 @@
/* eslint-disable global-require */
// Private angular devkit stuff
const {
generateI18nBrowserWebpackConfigFromContext,
} = require('@angular-devkit/build-angular/src/utils/webpack-browser-config');
const {
getCommonConfig,
getStylesConfig,
getDevServerConfig,
getTypeScriptConfig,
} = require('@angular-devkit/build-angular/src/webpack/configs');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const { filterOutStylingRules } = require('./utils/filter-out-styling-rules');
const {
default: StorybookNormalizeAngularEntryPlugin,
} = require('./plugins/storybook-normalize-angular-entry-plugin');

const getAngularWebpackUtils = () => {
try {
// Angular < 16.1.0
const {
getCommonConfig,
getStylesConfig,
getDevServerConfig,
getTypeScriptConfig,
} = require('@angular-devkit/build-angular/src/webpack/configs');

return {
getCommonConfig,
getStylesConfig,
getDevServerConfig,
getTypeScriptConfig,
};
} catch (e) {
// Angular > 16.1.0
const {
getCommonConfig,
getStylesConfig,
getDevServerConfig,
getTypeScriptConfig,
} = require('@angular-devkit/build-angular/src/tools/webpack/configs');

return {
getCommonConfig,
getStylesConfig,
getDevServerConfig,
getTypeScriptConfig,
};
}
};

/**
* Extract webpack config from angular-cli 13.x.x
* ⚠️ This file is in JavaScript to not use TypeScript. Because current storybook TypeScript version is not compatible with Angular CLI.
Expand All @@ -26,6 +55,8 @@ exports.getWebpackConfig = async (baseConfig, { builderOptions, builderContext }
/**
* Get angular-cli Webpack config
*/
const { getCommonConfig, getStylesConfig, getDevServerConfig, getTypeScriptConfig } =
getAngularWebpackUtils();
const { config: cliConfig } = await generateI18nBrowserWebpackConfigFromContext(
{
// Default options
Expand Down

0 comments on commit e16d8e1

Please sign in to comment.