Skip to content

Commit

Permalink
Merge pull request #25652 from storybookjs/valentin/add-next-js-alias
Browse files Browse the repository at this point in the history
Next.js: Add webpack aliases for OpenTelemetry API
  • Loading branch information
valentinpalkovic authored Jan 23, 2024
2 parents bb7434c + ea8f5f6 commit 9e94c62
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions code/frameworks/nextjs/src/aliases/webpack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { Configuration as WebpackConfig } from 'webpack';

export const configureAliases = (baseConfig: WebpackConfig): void => {
baseConfig.resolve = {
...(baseConfig.resolve ?? {}),
alias: {
...(baseConfig.resolve?.alias ?? {}),
'@opentelemetry/api': 'next/dist/compiled/@opentelemetry/api',
},
};
};
2 changes: 2 additions & 0 deletions code/frameworks/nextjs/src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { configureNodePolyfills } from './nodePolyfills/webpack';
import { configureSWCLoader } from './swc/loader';
import { configureBabelLoader } from './babel/loader';
import { configureFastRefresh } from './fastRefresh/webpack';
import { configureAliases } from './aliases/webpack';

export const addons: PresetProperty<'addons'> = [
dirname(require.resolve(join('@storybook/preset-react-webpack', 'package.json'))),
Expand Down Expand Up @@ -161,6 +162,7 @@ export const webpackFinal: StorybookConfig['webpackFinal'] = async (baseConfig,
configureImages(baseConfig, nextConfig);
configureStyledJsx(baseConfig);
configureNodePolyfills(baseConfig);
configureAliases(baseConfig);

if (isDevelopment) {
configureFastRefresh(baseConfig);
Expand Down

0 comments on commit 9e94c62

Please sign in to comment.