Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve config documentation and remove 22 dependencies from cssnano (#…
…1168) * test: add configuration loading tests and docs Closes #904 Add tests for configuration loading and correct the documentation. * correct configuration file names in the docs * specify that the PostCss config overrides the cssnano-specific config * remove mention of cosmiconfig to avoid being tied to a single implementation * chore(deps): replace cosmiconfig with lilconfig Remove about 22 dependencies according to npm i --production (from 110 to 88 deps) * reduce node_modules after `yarn install cssnano` in empty project from 14MB to 13MB * add YAML dep to preserve YAML configuration compatibility YAML configuration was only implicitly documented by referring to cosmiconfig, but removing it would be a breaking change
- Loading branch information
1 parent
9886775
commit 506a823
Showing
6 changed files
with
117 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
packages/cssnano/src/__tests__/config_loading/.cssnanorc.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"preset": "lite" | ||
} |
22 changes: 22 additions & 0 deletions
22
packages/cssnano/src/__tests__/config_loading/config-loading.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import process from 'process'; | ||
import postcss from 'postcss'; | ||
import litePreset from 'cssnano-preset-lite'; | ||
import defaultPreset from 'cssnano-preset-default'; | ||
import cssnano from '../..'; | ||
|
||
/* The configuration is loaded relative to the current working directory, | ||
when running the repository tests, the working directory is | ||
the repostiory root, so we need to change it to avoid having to place | ||
the configuration file for this test in the repo root */ | ||
const spy = jest.spyOn(process, 'cwd'); | ||
spy.mockReturnValue(__dirname); | ||
|
||
test('should read the cssnano configuration file', () => { | ||
const processor = postcss([cssnano]); | ||
expect(processor.plugins.length).toBe(litePreset().plugins.length); | ||
}); | ||
|
||
test('PostCSS config should override the cssnano config', () => { | ||
const processor = postcss([cssnano({ preset: 'default' })]); | ||
expect(processor.plugins.length).toBe(defaultPreset().plugins.length); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters