Skip to content

Commit d96d95d

Browse files
authored
fix: use sourceMapFilename in source map plugins (#676)
1 parent ac9ec0f commit d96d95d

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

packages/haul-core/src/preset/__tests__/__snapshots__/makeConfigFactory.test.ts.snap

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ Object {
104104
"libraryTarget": "this",
105105
"path": "<<REPLACED>>/packages/haul-core/src/preset/__tests__",
106106
"publicPath": "http://localhost:8081/",
107+
"sourceMapFilename": "[file].map",
107108
},
108109
"plugins": Array [
109110
DefinePlugin {
@@ -174,6 +175,7 @@ Object {
174175
"libraryTarget": "this",
175176
"path": "<<REPLACED>>/packages/haul-core/src/preset/__tests__",
176177
"publicPath": "http://localhost:8081/",
178+
"sourceMapFilename": "[file].map",
177179
},
178180
"plugins": Array [
179181
DefinePlugin {
@@ -239,6 +241,7 @@ Object {
239241
"globalObject": "this",
240242
"path": "<<REPLACED>>/packages/haul-core/src/preset/__tests__",
241243
"publicPath": "http://localhost:8081/",
244+
"sourceMapFilename": "[file].map",
242245
},
243246
"plugins": Array [
244247
DefinePlugin {
@@ -397,6 +400,7 @@ Object {
397400
"libraryTarget": "this",
398401
"path": "<<REPLACED>>/packages/haul-core/src/preset/__tests__",
399402
"publicPath": "http://localhost:8081/",
403+
"sourceMapFilename": "[file].map",
400404
},
401405
"plugins": Array [
402406
DefinePlugin {
@@ -461,6 +465,7 @@ Object {
461465
"libraryTarget": "this",
462466
"path": "<<REPLACED>>/packages/haul-core/src/preset/__tests__",
463467
"publicPath": "http://localhost:8081/",
468+
"sourceMapFilename": "[file].map",
464469
},
465470
"plugins": Array [
466471
DefinePlugin {
@@ -520,6 +525,7 @@ Object {
520525
"globalObject": "this",
521526
"path": "<<REPLACED>>/packages/haul-core/src/preset/__tests__",
522527
"publicPath": "http://localhost:8081/",
528+
"sourceMapFilename": "[file].map",
523529
},
524530
"plugins": Array [
525531
DefinePlugin {
@@ -628,6 +634,7 @@ Object {
628634
"globalObject": "this",
629635
"path": "<<REPLACED>>/packages/haul-core/src/preset/__tests__",
630636
"publicPath": "http://localhost:8081/",
637+
"sourceMapFilename": "[file].map",
631638
},
632639
"plugins": Array [
633640
DefinePlugin {

packages/haul-core/src/preset/makeConfigFactory.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,15 @@ export default function makeConfigFactory(getDefaultConfig: GetDefaultConfig) {
189189
webpackConfig.output!.path!,
190190
path.join(normalizedBundleConfig.root, env.sourcemapOutput)
191191
);
192+
} else {
193+
webpackConfig.output!.sourceMapFilename = '[file].map';
192194
}
193195

194196
webpackConfig.plugins = (webpackConfig.plugins || [])
195197
.concat(getSourceMapPlugin(
196198
normalizedBundleConfig,
197-
normalizedServerConfig
199+
normalizedServerConfig,
200+
webpackConfig.output!.sourceMapFilename
198201
) as webpack.Plugin)
199202
.filter(Boolean);
200203

packages/haul-core/src/preset/utils/getSourceMapPlugin.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import {
66

77
export default function getSourceMapPlugin(
88
bundleConfig: NormalizedBundleConfig,
9-
serverConfig: NormalizedServerConfig
9+
serverConfig: NormalizedServerConfig,
10+
sourceMapFilename: string
1011
) {
1112
const baseOptions = {
1213
test: /\.(js|jsx|css|ts|tsx|(js)?bundle)($|\?)/i,
@@ -21,7 +22,7 @@ export default function getSourceMapPlugin(
2122
} else if (bundleConfig.sourceMap) {
2223
return new webpack.SourceMapDevToolPlugin({
2324
...baseOptions,
24-
filename: '[file].map',
25+
filename: sourceMapFilename,
2526
moduleFilenameTemplate: '[absolute-resource-path]',
2627
});
2728
}

0 commit comments

Comments
 (0)