Skip to content

Commit 985fb0d

Browse files
committed
use loader in webpack config
1 parent 2802a6c commit 985fb0d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

packages/nextjs/src/config/webpack.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable max-lines */
22
import { getSentryRelease } from '@sentry/node';
3-
import { dropUndefinedKeys, logger } from '@sentry/utils';
3+
import { dropUndefinedKeys, escapeStringForRegex, logger } from '@sentry/utils';
44
import { default as SentryWebpackPlugin } from '@sentry/webpack-plugin';
55
import * as fs from 'fs';
66
import * as path from 'path';
@@ -53,6 +53,8 @@ export function constructWebpackConfigFunction(
5353
newConfig = userNextConfig.webpack(newConfig, buildContext);
5454
}
5555

56+
const pageRegex = new RegExp(`${escapeStringForRegex(projectDir)}(/src)?/pages(/.+)\\.(jsx?|tsx?)`);
57+
5658
if (isServer) {
5759
newConfig.module = {
5860
...newConfig.module,
@@ -72,6 +74,15 @@ export function constructWebpackConfigFunction(
7274
},
7375
],
7476
},
77+
{
78+
test: pageRegex,
79+
use: [
80+
{
81+
loader: path.resolve(__dirname, 'loaders/dataFetchersLoader.js'),
82+
options: { projectDir },
83+
},
84+
],
85+
},
7586
],
7687
};
7788
}

0 commit comments

Comments
 (0)