Skip to content

Commit

Permalink
Update section titles, move verbosity to new Debugging section, forma…
Browse files Browse the repository at this point in the history
…t and copy tweaks
  • Loading branch information
banagale committed Nov 3, 2020
1 parent 17bcc63 commit 1912be6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 49 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ All you have to do is create your app using [create-react-app](https://github.co
- Custom `react-scripts` version

## Documentation
- [Preface](https://github.com/sharegate/craco/blob/master/packages/craco/README.md#preface)
- [Installation](https://github.com/sharegate/craco/blob/master/packages/craco/README.md#installation)
- [CRACO Configuration](https://github.com/sharegate/craco/blob/master/packages/craco/README.md#craco-configuration)
- [Configuration](https://github.com/sharegate/craco/blob/master/packages/craco/README.md#configuration)
- [The Mode Property](https://github.com/sharegate/craco/blob/master/packages/craco/README.md#the-mode-property)
- [Sample CRACO Configuration File](https://github.com/sharegate/craco/blob/master/packages/craco/README.md#sample-craco-configuration-file)
- [Setting a Custom Location for `craco.config.js`](https://github.com/sharegate/craco/blob/master/packages/craco/README.md#setting-a-custom-location-for-cracoconfigjs)
Expand All @@ -32,18 +31,20 @@ All you have to do is create your app using [create-react-app](https://github.co
- [Notes on CRA Configurations and Problem Solving](https://github.com/sharegate/craco/blob/master/packages/craco/README.md#notes-on-cra-configurations-and-problem-solving)
- [Ejecting CRA to Learn](https://github.com/sharegate/craco/blob/master/packages/craco/README.md#ejecting-cra-to-learn)
- [Direct Versus Functional Config Definitions](https://github.com/sharegate/craco/blob/master/packages/craco/README.md#direct-object-literal-versus-functional-config-definitions)
- [CRACO API](https://github.com/sharegate/craco/blob/master/packages/craco/README.md#craco-api) - Access CRACO-generated configurations for Jest and Webpack
- [API](https://github.com/sharegate/craco/blob/master/packages/craco/README.md#api) - Access CRACO-generated configurations for Jest and Webpack
- [Jest Config Generation](https://github.com/sharegate/craco/blob/master/packages/craco/README.md#jest-config-generation)
- [Webpack DevServer and Production Config Generation](https://github.com/sharegate/craco/blob/master/packages/craco/README.md#webpack-devserver-and-production-config-generation)
- [Recipes](https://github.com/sharegate/craco/blob/master/packages/craco/README.md#recipes)
- [Plugins](https://github.com/sharegate/craco/blob/master/packages/craco/README.md#plugins)
- [Available Plugins](#community-maintained-plugins)
- [Available Plugins](#community-maintained-plugins) - Plugins maintained by the community.
- [Developing a New Plugin](https://github.com/sharegate/craco/blob/master/packages/craco/README.md#developing-a-new-plugin) - How to develop a plugin for CRACO.
- [Plugin Functions](https://github.com/sharegate/craco/blob/master/packages/craco/README.md#plugin-functions)
- [Utility Functions for Development](https://github.com/sharegate/craco/blob/master/packages/craco/README.md#utility-functions-for-development)
- [Debugging](https://github.com/sharegate/craco/blob/master/packages/craco/README.md#debugging)
- [Verbose Logging](https://github.com/sharegate/craco/blob/master/packages/craco/README.md#verbose-logging)
- [License](#license)

## Community Maintained Plugins

* [craco-preact](https://github.com/FormAPI/craco-preact) by [@FormAPI](https://github.com/FormAPI)
* [craco-less](https://github.com/FormAPI/craco-less) by [@FormAPI](https://github.com/FormAPI)
* [craco-antd](https://github.com/FormAPI/craco-antd) by [@FormAPI](https://github.com/FormAPI)
Expand All @@ -66,9 +67,8 @@ All you have to do is create your app using [create-react-app](https://github.co
* [craco-fast-refresh](https://github.com/vimcaw/craco-fast-refresh) by [@vimcaw](https://github.com/vimcaw)

## Acknowledgements

[@timarney](https://github.com/timarney) for having created [react-app-rewired](https://github.com/timarney/react-app-rewired).

## License

Copyright © 2020, GSoft inc. This code is licensed under the Apache License, Version 2.0. You may obtain a copy of this license at https://github.com/gsoft-inc/gsoft-license/blob/master/LICENSE.
Copyright © 2020, Groupe Sharegate inc. This code is licensed under the Apache License, Version 2.0. You may obtain a
copy of this license at https://github.com/gsoft-inc/gsoft-license/blob/master/LICENSE.
65 changes: 24 additions & 41 deletions packages/craco/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Get all the benefits of create-react-app **and** customization without using 'ej
All you have to do is create your app using [create-react-app](https://github.com/facebook/create-react-app/) and customize the configuration with a `craco.config.js` file.

## Support

- Create React App (CRA) 3.*
- Yarn
- Yarn Workspace
Expand All @@ -16,9 +15,8 @@ All you have to do is create your app using [create-react-app](https://github.co
- Custom `react-scripts` version

## Documentation
- [Preface](#preface)
- [Installation](#installation)
- [CRACO Configuration](#craco-configuration)
- [Configuration](#configuration)
- [The Mode Property](#the-mode-property)
- [Sample CRACO Configuration File](#sample-craco-configuration-file)
- [Setting a Custom Location for `craco.config.js`](#setting-a-custom-location-for-cracoconfigjs)
Expand All @@ -27,15 +25,18 @@ All you have to do is create your app using [create-react-app](https://github.co
- [Notes on CRA Configurations and Problem Solving](#notes-on-cra-configurations-and-problem-solving)
- [Ejecting CRA to Learn](#ejecting-cra-to-learn)
- [Direct Versus Functional Config Definitions](#direct-object-literal-versus-functional-config-definitions)
- [CRACO API](#craco-api) - Access CRACO-generated configurations for Jest and Webpack
- [API](#api) - Access CRACO-generated configurations for Jest and Webpack
- [Jest Config Generation](#jest-config-generation)
- [Webpack DevServer and Production Config Generation](#webpack-devserver-and-production-config-generation)
- [Recipes](#recipes)
- [Plugins](#plugins)
- [Available Plugins](https://github.com/sharegate/craco#community-maintained-plugins) - Plugins maintained by the community.
- [Developing a New Plugin](#developing-a-new-plugin) - How to develop a plugin for CRACO.
- [Available Plugins](https://github.com/sharegate/craco#community-maintained-plugins) - Plugins maintained by the community
- [Developing a New Plugin](#developing-a-new-plugin) - How to develop a plugin for CRACO
- [Plugin Functions](#plugin-functions)
- [Utility Functions for Development](#utility-functions-for-development)
- [Debugging](#debugging)
- [Verbose Logging](#verbose-logging)
- [License](#license)

## Preface
### Acknowledgements
Expand Down Expand Up @@ -135,21 +136,7 @@ Or build your app:
$ npm run build
```

### Verbose logging

To activate **verbose** logging specify the CLI option `--verbose`

```javascript
/* package.json */

{
"scripts": {
"start": "craco start --verbose"
}
}
```

## CRACO Configuration
## Configuration
CRACO is configured with the `craco.config.js` file. This file is divided into sections representing the major
parts of what makes up the default create react app.

Expand Down Expand Up @@ -242,7 +229,6 @@ module.exports = {
```

### Setting a custom location for craco.config.js

Both options support a **relative** or an **absolute** path.

**1- package.json** _(Recommended)_
Expand Down Expand Up @@ -369,7 +355,7 @@ devServer: (devServerConfig, { env, paths, proxy, allowedHost }) => {
},
```

## CRACO API
## API
### Overview
If you would like to integrate with other tools, you may want access to configurations generated by CRACO.

Expand Down Expand Up @@ -433,7 +419,7 @@ already built for common use cases
See this list of [Available Plugins](https://github.com/sharegate/craco#community-maintained-plugins) maintained by the
community.

### Developing a new plugin
### Developing a New Plugin
#### Plugin Functions
There are four functions available to a plugin:
- `overrideCracoConfig`: Let a plugin customize the config object before it's process by `craco`.
Expand All @@ -446,7 +432,6 @@ There are four functions available to a plugin:
Every function must return the updated config object.

##### overrideCracoConfig

The function `overrideCracoConfig` let a plugin override the config object **before** it's process by `craco`.

If a plugin define the function, it will be called with the config object read from the `craco.config.js` file provided
Expand All @@ -468,7 +453,6 @@ The function will be called with a single object argument having the following s
```

###### Example

Plugin:

```javascript
Expand Down Expand Up @@ -502,7 +486,6 @@ module.exports = {
```

##### overrideWebpackConfig

The function `overrideWebpackConfig` let a plugin override the `webpack` config object **after** it's been customized
by `craco`.

Expand All @@ -523,7 +506,6 @@ The function will be called with a single object argument having the following s
```

###### Example

Plugin:

```javascript
Expand Down Expand Up @@ -557,7 +539,6 @@ module.exports = {
```

##### overrideDevServerConfig

The function `overrideDevServerConfig` let a plugin override the dev server config object **after** it's been customized
by `craco`.

Expand All @@ -579,7 +560,6 @@ The function will be called with a single object argument having the following s
```

###### Example

Plugin:

```javascript
Expand Down Expand Up @@ -613,7 +593,6 @@ module.exports = {
```

##### overrideJestConfig

The function `overrideJestConfig` let a plugin override the `Jest` config object **after** it's been customized by
`craco`.

Expand All @@ -636,7 +615,6 @@ The function will be called with a single object argument having the following s
```

###### Example

Plugin:

```javascript
Expand Down Expand Up @@ -685,7 +663,6 @@ const { getLoader, getLoaders, removeLoader, loaderByName, throwUnexpectedConfig
```

##### getLoader

Retrieve the **first** loader that match the specified criteria from the webpack config.

Returns:
Expand Down Expand Up @@ -714,7 +691,6 @@ if (isFound) {
```

##### getLoaders

Retrieve **all** the loaders that match the specified criteria from the webpack config.

Returns:
Expand Down Expand Up @@ -747,7 +723,6 @@ if (hasFoundAny) {
```

##### removeLoaders

Remove **all** the loaders that match the specified criteria from the webpack config.

Returns:
Expand All @@ -768,7 +743,6 @@ removeLoaders(webpackConfig, loaderByName("eslint-loader"));
```

##### addBeforeLoader

Add a new *loader* **before** the loader that match specified criteria to the webpack config.

Returns:
Expand All @@ -792,7 +766,6 @@ addBeforeLoader(webpackConfig, loaderByName("eslint-loader"), myNewWebpackLoader
```

##### addBeforeLoaders

Add a new *loader* **before** all the loaders that match specified criteria to the webpack config.

Returns:
Expand All @@ -817,7 +790,6 @@ addBeforeLoaders(webpackConfig, loaderByName("eslint-loader"), myNewWebpackLoade
```

##### addAfterLoader

Add a new *loader* **after** the loader that match specified criteria to the webpack config.

Returns:
Expand All @@ -841,7 +813,6 @@ addAfterLoader(webpackConfig, loaderByName("eslint-loader"), myNewWebpackLoader)
```

##### addAfterLoaders

Add a new *loader* **after** all the loaders that match specified criteria to the webpack config.

Returns:
Expand All @@ -866,7 +837,6 @@ addAfterLoaders(webpackConfig, loaderByName("eslint-loader"), myNewWebpackLoader
```

##### throwUnexpectedConfigError

Throw an error if the webpack configuration changes and does not match your expectations. (For example, `getLoader`
cannot find a loader and `isFound` is `false`.) `create-react-app` might update the structure of their webpack config,
so it is very important to show a helpful error message when something breaks.
Expand Down Expand Up @@ -941,7 +911,20 @@ Options:
> Only `message` is required.
## License
## Debugging
### Verbose Logging
To activate **verbose** logging specify the CLI option `--verbose`
```javascript
/* package.json */

{
"scripts": {
"start": "craco start --verbose"
}
}
```
## License
Copyright © 2020, Groupe Sharegate inc. This code is licensed under the Apache License, Version 2.0. You may obtain a
copy of this license at https://github.com/gsoft-inc/gsoft-license/blob/master/LICENSE.

0 comments on commit 1912be6

Please sign in to comment.