Skip to content

Commit

Permalink
use loader in webpack config
Browse files Browse the repository at this point in the history
  • Loading branch information
lobsterkatie committed Aug 4, 2022
1 parent 2802a6c commit 985fb0d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/nextjs/src/config/webpack.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable max-lines */
import { getSentryRelease } from '@sentry/node';
import { dropUndefinedKeys, logger } from '@sentry/utils';
import { dropUndefinedKeys, escapeStringForRegex, logger } from '@sentry/utils';
import { default as SentryWebpackPlugin } from '@sentry/webpack-plugin';
import * as fs from 'fs';
import * as path from 'path';
Expand Down Expand Up @@ -53,6 +53,8 @@ export function constructWebpackConfigFunction(
newConfig = userNextConfig.webpack(newConfig, buildContext);
}

const pageRegex = new RegExp(`${escapeStringForRegex(projectDir)}(/src)?/pages(/.+)\\.(jsx?|tsx?)`);

if (isServer) {
newConfig.module = {
...newConfig.module,
Expand All @@ -72,6 +74,15 @@ export function constructWebpackConfigFunction(
},
],
},
{
test: pageRegex,
use: [
{
loader: path.resolve(__dirname, 'loaders/dataFetchersLoader.js'),
options: { projectDir },
},
],
},
],
};
}
Expand Down

0 comments on commit 985fb0d

Please sign in to comment.