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

perf: enable cache by default #327

Merged
merged 7 commits into from
Apr 10, 2023
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
3 changes: 2 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"badstylelintrc",
"indentifies",
"stylelintignore",
"notcss"
"notcss",
"stylelintcache"
],

"ignorePaths": [
Expand Down
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,30 @@ module.exports = {

See [stylelint's options](https://stylelint.io/user-guide/usage/node-api#options) for the complete list of options available. These options are passed through to the `stylelint` directly.

### `cache`

- Type:

```ts
type cache = boolean;
```

- Default: `true`

The cache is enabled by default to decrease execution time.

### `cacheLocation`

- Type:

```ts
type cacheLocation = string;
```

- Default: `node_modules/.cache/stylelint-webpack-plugin/.stylelintcache`

Specify the path to the cache location. Can be a file or a directory.

### `configFile`

- Type:
Expand Down
2 changes: 2 additions & 0 deletions src/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ const schema = require('./options.json');
*/
function getOptions(pluginOptions) {
const options = {
cache: true,
cacheLocation: 'node_modules/.cache/stylelint-webpack-plugin/.stylelintcache',
extensions: ['css', 'scss', 'sass'],
emitError: true,
emitWarning: true,
Expand Down
14 changes: 12 additions & 2 deletions test/stylelint-lint.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ describe('stylelint lint', () => {

compiler.run((err) => {
const files = [expect.stringMatching('test.scss')];
expect(mockLintFiles).toHaveBeenCalledWith({ configFile: null, files });
expect(mockLintFiles).toHaveBeenCalledWith({
cache: true,
cacheLocation: 'node_modules/.cache/stylelint-webpack-plugin/.stylelintcache',
configFile: null,
files,
});
expect(err).toBeNull();
done();
});
Expand All @@ -40,7 +45,12 @@ describe('stylelint lint', () => {
expect.stringMatching(/test[12]\.scss$/),
expect.stringMatching(/test[12]\.scss$/),
];
expect(mockLintFiles).toHaveBeenCalledWith({ configFile: null, files });
expect(mockLintFiles).toHaveBeenCalledWith({
cache: true,
cacheLocation: 'node_modules/.cache/stylelint-webpack-plugin/.stylelintcache',
configFile: null,
files,
});
expect(err).toBeNull();
done();
});
Expand Down