mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-03-26 10:14:19 +08:00
Cache identifier follow up (#5055)
* Tweak environment handling * Add documentation for getCacheIdentifier
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
This package includes some utilities used by [Create React App](https://github.com/facebook/create-react-app).<br>
|
||||
Please refer to its documentation:
|
||||
|
||||
* [Getting Started](https://github.com/facebook/create-react-app/blob/master/README.md#getting-started) – How to create a new app.
|
||||
* [User Guide](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md) – How to develop apps bootstrapped with Create React App.
|
||||
- [Getting Started](https://github.com/facebook/create-react-app/blob/master/README.md#getting-started) – How to create a new app.
|
||||
- [User Guide](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md) – How to develop apps bootstrapped with Create React App.
|
||||
|
||||
## Usage in Create React App Projects
|
||||
|
||||
@@ -361,3 +361,13 @@ module: {
|
||||
];
|
||||
}
|
||||
```
|
||||
|
||||
#### `getCacheIdentifier(environment: string, packages: string[]): string`
|
||||
|
||||
Returns a cache identifier (string) consisting of the specified environment and related package versions, e.g.,
|
||||
|
||||
```js
|
||||
var getCacheIdentifier = require('react-dev-utils/getCacheIdentifier');
|
||||
|
||||
getCacheIdentifier('prod', ['react-dev-utils', 'chalk']); // # => 'prod:react-dev-utils@5.0.0:chalk@2.4.1'
|
||||
```
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function getCacheIdentifier(environment, packages) {
|
||||
let cacheIdentifier = `${environment}`;
|
||||
let cacheIdentifier = environment == null ? '' : environment.toString();
|
||||
for (const packageName of packages) {
|
||||
cacheIdentifier += `:${packageName}@`;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user