Skip to content

Commit 2fe9ae7

Browse files
perf: enable cache by default (#327)
* perf: enable cache by default * test: update with cache * chore: add stylelintcache * fix: update `cacheLocation` * test: update `cacheLocation` * docs: update `cacheLocation`
1 parent 859f5a5 commit 2fe9ae7

File tree

4 files changed

+40
-3
lines changed

4 files changed

+40
-3
lines changed

.cspell.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"badstylelintrc",
1414
"indentifies",
1515
"stylelintignore",
16-
"notcss"
16+
"notcss",
17+
"stylelintcache"
1718
],
1819

1920
"ignorePaths": [

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,30 @@ module.exports = {
7676

7777
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.
7878

79+
### `cache`
80+
81+
- Type:
82+
83+
```ts
84+
type cache = boolean;
85+
```
86+
87+
- Default: `true`
88+
89+
The cache is enabled by default to decrease execution time.
90+
91+
### `cacheLocation`
92+
93+
- Type:
94+
95+
```ts
96+
type cacheLocation = string;
97+
```
98+
99+
- Default: `node_modules/.cache/stylelint-webpack-plugin/.stylelintcache`
100+
101+
Specify the path to the cache location. Can be a file or a directory.
102+
79103
### `configFile`
80104

81105
- Type:

src/options.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ const schema = require('./options.json');
3737
*/
3838
function getOptions(pluginOptions) {
3939
const options = {
40+
cache: true,
41+
cacheLocation: 'node_modules/.cache/stylelint-webpack-plugin/.stylelintcache',
4042
extensions: ['css', 'scss', 'sass'],
4143
emitError: true,
4244
emitWarning: true,

test/stylelint-lint.test.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ describe('stylelint lint', () => {
2626

2727
compiler.run((err) => {
2828
const files = [expect.stringMatching('test.scss')];
29-
expect(mockLintFiles).toHaveBeenCalledWith({ configFile: null, files });
29+
expect(mockLintFiles).toHaveBeenCalledWith({
30+
cache: true,
31+
cacheLocation: 'node_modules/.cache/stylelint-webpack-plugin/.stylelintcache',
32+
configFile: null,
33+
files,
34+
});
3035
expect(err).toBeNull();
3136
done();
3237
});
@@ -40,7 +45,12 @@ describe('stylelint lint', () => {
4045
expect.stringMatching(/test[12]\.scss$/),
4146
expect.stringMatching(/test[12]\.scss$/),
4247
];
43-
expect(mockLintFiles).toHaveBeenCalledWith({ configFile: null, files });
48+
expect(mockLintFiles).toHaveBeenCalledWith({
49+
cache: true,
50+
cacheLocation: 'node_modules/.cache/stylelint-webpack-plugin/.stylelintcache',
51+
configFile: null,
52+
files,
53+
});
4454
expect(err).toBeNull();
4555
done();
4656
});

0 commit comments

Comments
 (0)