Skip to content

Commit

Permalink
fix: source map url for devtool (only webpack@5) (#650)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored Nov 6, 2020
1 parent 022d945 commit 5889d43
Show file tree
Hide file tree
Showing 15 changed files with 52 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import schema from './plugin-options.json';
import { MODULE_TYPE, compareModulesByIdentifier } from './utils';

// webpack 5 exposes the sources property to ensure the right version of webpack-sources is used
const { ConcatSource, SourceMapSource, OriginalSource } =
const { ConcatSource, SourceMapSource, RawSource } =
// eslint-disable-next-line global-require
webpack.sources || require('webpack-sources');

Expand Down Expand Up @@ -688,7 +688,7 @@ class MiniCssExtractPlugin {
);
} else {
source.add(
new OriginalSource(content, m.readableIdentifier(requestShortener))
new RawSource(content, m.readableIdentifier(requestShortener))
);
}
source.add('\n');
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions test/cases/devtool-source-map-from-loaders/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import Self from '../../../src';

module.exports = {
entry: './index.js',
devtool: 'source-map',
module: {
rules: [
{
test: /\.css$/,
use: [
Self.loader,
{
loader: 'css-loader',
options: {
sourceMap: true,
},
},
],
},
],
},
plugins: [
new Self({
filename: '[name].css',
}),
],
};

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
body {
background: red;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './style.css';
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
background: red;
}

0 comments on commit 5889d43

Please sign in to comment.