Skip to content

Commit 88e86ab

Browse files
refactor: respect the devtool option (#1105)
BREAKING CHANGE: default value of the `sourceMap` option depends on the `devtool` option
1 parent 3b47d0d commit 88e86ab

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

README.md

+12-16
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,16 @@ module.exports = {
109109

110110
## Options
111111

112-
| Name | Type | Default | Description |
113-
| :-----------------------------------------: | :-------------------------: | :------: | :--------------------------------------------------------------------- |
114-
| **[`url`](#url)** | `{Boolean\|Function}` | `true` | Enables/Disables `url`/`image-set` functions handling |
115-
| **[`import`](#import)** | `{Boolean\|Function}` | `true` | Enables/Disables `@import` at-rules handling |
116-
| **[`modules`](#modules)** | `{Boolean\|String\|Object}` | `false` | Enables/Disables CSS Modules and their configuration |
117-
| **[`sourceMap`](#sourcemap)** | `{Boolean}` | `false` | Enables/Disables generation of source maps |
118-
| **[`importLoaders`](#importloaders)** | `{Number}` | `0` | Enables/Disables or setups number of loaders applied before CSS loader |
119-
| **[`localsConvention`](#localsconvention)** | `{String}` | `'asIs'` | Style of exported classnames |
120-
| **[`onlyLocals`](#onlylocals)** | `{Boolean}` | `false` | Export only locals |
121-
| **[`esModule`](#esmodule)** | `{Boolean}` | `false` | Use ES modules syntax |
112+
| Name | Type | Default | Description |
113+
| :-----------------------------------------: | :-------------------------: | :----------------: | :--------------------------------------------------------------------- |
114+
| **[`url`](#url)** | `{Boolean\|Function}` | `true` | Enables/Disables `url`/`image-set` functions handling |
115+
| **[`import`](#import)** | `{Boolean\|Function}` | `true` | Enables/Disables `@import` at-rules handling |
116+
| **[`modules`](#modules)** | `{Boolean\|String\|Object}` | `false` | Enables/Disables CSS Modules and their configuration |
117+
| **[`sourceMap`](#sourcemap)** | `{Boolean}` | `compiler.devtool` | Enables/Disables generation of source maps |
118+
| **[`importLoaders`](#importloaders)** | `{Number}` | `0` | Enables/Disables or setups number of loaders applied before CSS loader |
119+
| **[`localsConvention`](#localsconvention)** | `{String}` | `'asIs'` | Style of exported classnames |
120+
| **[`onlyLocals`](#onlylocals)** | `{Boolean}` | `false` | Export only locals |
121+
| **[`esModule`](#esmodule)** | `{Boolean}` | `false` | Use ES modules syntax |
122122

123123
### `url`
124124

@@ -869,13 +869,9 @@ module.exports = {
869869
### `sourceMap`
870870

871871
Type: `Boolean`
872-
Default: `false`
873-
874-
Enables/Disables generation of source maps.
875-
876-
To include source maps set the `sourceMap` option.
872+
Default: depends on the `compiler.devtool` value
877873

878-
They are not enabled by default because they expose a runtime overhead and increase in bundle size (JS source maps do not).
874+
By default generation of source maps depends on the [`devtool`](https://webpack.js.org/configuration/devtool/) option. All values enable source map generation except `eval` and `false` value.
879875

880876
**webpack.config.js**
881877

src/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ export default function loader(content, map, meta) {
3232
});
3333

3434
const callback = this.async();
35-
const sourceMap = options.sourceMap || false;
35+
const sourceMap =
36+
typeof options.sourceMap === 'boolean' ? options.sourceMap : this.sourceMap;
3637
const plugins = [];
3738

3839
const exportType = options.onlyLocals ? 'locals' : 'full';

0 commit comments

Comments
 (0)