Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: exportOnlyLocals was remove in favor new onlyLocals option #957

Merged
merged 1 commit into from
Jun 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ module.exports = {
| **[`sourceMap`](#sourcemap)** | `{Boolean}` | `false` | Enable/Disable Sourcemaps |
| **[`importLoaders`](#importloaders)** | `{Number}` | `0` | Number of loaders applied before CSS loader |
| **[`exportLocalsStyle`](#exportlocalsstyle)** | `{String}` | `asIs` | Setup style of exported classnames |
| **[`exportOnlyLocals`](#exportonlylocals)** | `{Boolean}` | `false` | Export only locals |
| **[`onlyLocals`](#onlylocals)** | `{Boolean}` | `false` | Export only locals |

### `url`

Expand Down Expand Up @@ -772,7 +772,7 @@ By default, the exported JSON keys mirror the class names (i.e `asIs` value).

| Name | Type | Description |
| :-------------------: | :--------: | :----------------------------------------------------------------------------------------------- |
| **`asIs`** | `{String}` | Class names will be exported as is. |
| **`'asIs'`** | `{String}` | Class names will be exported as is. |
| **`'camelCase'`** | `{String}` | Class names will be camelized, the original class name will not to be removed from the locals |
| **`'camelCaseOnly'`** | `{String}` | Class names will be camelized, the original class name will be removed from the locals |
| **`'dashes'`** | `{String}` | Only dashes in class names will be camelized |
Expand Down Expand Up @@ -809,7 +809,7 @@ module.exports = {
};
```

### `exportOnlyLocals`
### `onlyLocals`

Type: `Boolean`
Default: `false`
Expand All @@ -828,7 +828,7 @@ module.exports = {
test: /\.css$/i,
loader: 'css-loader',
options: {
exportOnlyLocals: true,
onlyLocals: true,
},
},
],
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default function loader(content, map, meta) {
result.messages = [];
}

const { exportOnlyLocals: onlyLocals } = options;
const { onlyLocals } = options;

const importItems = result.messages
.filter((message) => (message.type === 'import' ? message : false))
Expand Down
2 changes: 1 addition & 1 deletion src/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
}
]
},
"exportOnlyLocals": {
"onlyLocals": {
"type": "boolean"
}
},
Expand Down
2 changes: 1 addition & 1 deletion test/__snapshots__/validate-options.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,6 @@ options.importLoaders should match some schema in anyOf
exports[`validate options 18`] = `
"CSS Loader Invalid Options

options.exportOnlyLocals should be boolean
options.onlyLocals should be boolean
"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('modules', () => {
mode: 'local',
localIdentName: '_[local]',
},
exportOnlyLocals: true,
onlyLocals: true,
},
},
};
Expand Down
8 changes: 3 additions & 5 deletions test/validate-options.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ it('validate options', () => {
expect(() => validate({ importLoaders: 2 })).not.toThrow();
expect(() => validate({ importLoaders: '1' })).toThrowErrorMatchingSnapshot();

expect(() => validate({ exportOnlyLocals: true })).not.toThrow();
expect(() => validate({ exportOnlyLocals: false })).not.toThrow();
expect(() =>
validate({ exportOnlyLocals: 'true' })
).toThrowErrorMatchingSnapshot();
expect(() => validate({ onlyLocals: true })).not.toThrow();
expect(() => validate({ onlyLocals: false })).not.toThrow();
expect(() => validate({ onlyLocals: 'true' })).toThrowErrorMatchingSnapshot();
});