Skip to content

Commit 4a06bd5

Browse files
authored
Merge pull request #144 from mzgoddard/direct-source-map-plugin
Fetch the source map options from a manual SourceMapDevToolPlugin
2 parents 12c4b2d + a7cc944 commit 4a06bd5

File tree

5 files changed

+51
-0
lines changed

5 files changed

+51
-0
lines changed

lib/devtool-options.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module.exports = function(options) {
22
var devtool = options.devtool;
3+
// options.devtool is turned into the options for SourceMapDevToolPlugin
34
if(devtool && (devtool.indexOf("sourcemap") >= 0 || devtool.indexOf("source-map") >= 0)) {
45
var hidden = devtool.indexOf("hidden") >= 0;
56
var inline = devtool.indexOf("inline") >= 0;
@@ -24,4 +25,15 @@ module.exports = function(options) {
2425
noSources: noSources,
2526
};
2627
}
28+
29+
// A SourceMapDevToolPlugin was manually set on the compiler's plugins
30+
if (options.plugins) {
31+
var plugins = options.plugins;
32+
for (var i = 0; i < plugins.length; i++) {
33+
var plugin = plugins[i];
34+
if (plugin.sourceMapFilename) {
35+
return plugin.options;
36+
}
37+
}
38+
}
2739
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = function(n) {
2+
return n + (n > 0 ? n - 1 : 0);
3+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
var fib = require('./fib');
2+
3+
console.log(fib(3));
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
var SourceMapDevToolPlugin = require('webpack').SourceMapDevToolPlugin;
2+
3+
var HardSourceWebpackPlugin = require('../../..');
4+
5+
module.exports = {
6+
context: __dirname,
7+
entry: './index.js',
8+
output: {
9+
path: __dirname + '/tmp',
10+
filename: 'main.js',
11+
},
12+
recordsPath: __dirname + '/tmp/cache/records.json',
13+
plugins: [
14+
new HardSourceWebpackPlugin({
15+
cacheDirectory: 'cache',
16+
environmentHash: {
17+
root: __dirname + '/../../..',
18+
},
19+
}),
20+
new SourceMapDevToolPlugin({
21+
filename: '[file].map[query]',
22+
moduleFilenameTemplate: undefined,
23+
fallbackModuleFilenameTemplate: undefined,
24+
append: null,
25+
module: true,
26+
columns: false,
27+
lineToLine: false,
28+
noSources: false,
29+
test: /\.(js|css)(\.out)?($|\?)/i,
30+
}),
31+
],
32+
};

tests/plugins-webpack-1.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ describe('plugin webpack use', function() {
3131
itCompilesTwice('plugin-child-compiler-resolutions');
3232
itCompilesTwice('plugin-logger-child-no-memory');
3333
itCompilesTwice('plugin-serializer-json-base-1dep');
34+
itCompilesTwice('plugin-source-map-1dep');
3435

3536
itCompilesHardModules('plugin-dll', ['./fib.js']);
3637
itCompilesHardModules('plugin-dll-reference', ['./index.js']);

0 commit comments

Comments
 (0)