forked from dilanx/craco
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f65049e
commit 12619e8
Showing
33 changed files
with
2,477 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = crlf | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
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,2 @@ | ||
/.vscode | ||
node_modules |
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,15 @@ | ||
module.exports = { | ||
extends: "eslint:recommended", | ||
env: { | ||
"commonjs": true, | ||
"node": true, | ||
"es6": true | ||
}, | ||
parserOptions: { | ||
"ecmaVersion": 2018 | ||
}, | ||
rules: { | ||
"no-console": "off", | ||
"curly": "warn" | ||
} | ||
}; |
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,9 @@ | ||
# See https://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
node_modules | ||
|
||
# misc | ||
.DS_Store | ||
|
||
npm-debug.log* |
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,2 @@ | ||
save-exact=true | ||
loglevel="error" |
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,10 @@ | ||
/.vscode | ||
/node_modules | ||
package.json | ||
package-lock.json | ||
.eslintrc.js | ||
.eslintignore | ||
.gitignore | ||
.npmrc | ||
.editorconfig | ||
README.md |
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,4 @@ | ||
module.exports = { | ||
printWidth: 5000, | ||
tabWidth: 4 | ||
}; |
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,12 @@ | ||
{ | ||
"recommendations": [ | ||
"formulahendry.auto-rename-tag", | ||
"editorconfig.editorconfig", | ||
"dbaeumer.vscode-eslint", | ||
"eg2.vscode-npm-script", | ||
"christian-kohler.npm-intellisense", | ||
"christian-kohler.path-intellisense", | ||
"esbenp.prettier-vscode", | ||
"amatiasq.sort-imports" | ||
] | ||
} |
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,11 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Node", | ||
"program": "${workspaceFolder}/src/scripts/start.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,20 @@ | ||
{ | ||
"editor.minimap.enabled": false, | ||
"editor.wordWrap": "off", | ||
// Turns on auto format on save for all files types. | ||
// This is also required to allow Prettier to auto format files on save. | ||
"editor.formatOnSave": true, | ||
// Turns it off for JavaScript since we use Prettier to auto format on save. | ||
"javascript.format.enable": false, | ||
"javascript.validate.enable": true, | ||
"json.format.enable": false, | ||
// Required to allow auto format on save with Prettier + ESLint + Vetur. | ||
"eslint.autoFixOnSave": true, | ||
"eslint.alwaysShowStatus": true, | ||
"prettier.eslintIntegration": true, | ||
"prettier.stylelintIntegration": true, | ||
"sort-imports.suppress-warnings": true, | ||
"search.exclude": { | ||
"**/node_modules*": true | ||
} | ||
} |
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,181 @@ | ||
# craco | ||
|
||
Create React App Configuration Override, an easy and comprehensible configuration layer for create-react-app v2. | ||
|
||
Get all the benefits of create-react-app **and** customization without using 'eject' by adding a single craco.config.js file at the root of your application and customize your eslint, babel, postcss configuration and many more.. | ||
|
||
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 craco.config.js file. | ||
|
||
- [Configuration Overview](#configuration-overview) - Quickly see how you can configure your CRA installation with this plugin. | ||
- [Recipes](#creating-an-app) – Short and easy recipes for common use cases. | ||
- [Documentation](#documentation) - Have a deep understanding on how you can configure your CRA installation with this plugin. | ||
- [Develop a Plugin]() - How to develop a plugin for `craco`. | ||
|
||
**Acknowledgements:** | ||
|
||
We are grateful to [@timarney](https://github.com/timarney) the creator of [react-app-rewired](https://github.com/timarney/react-app-rewired) for is original idea. | ||
|
||
Also, the configuration style of this plugin tend to be influenced by the way [Vue CLI](https://cli.vuejs.org/guide/) do it. | ||
|
||
**Please Note:** | ||
|
||
By doing this you're breaking the ["guarantees"](https://github.com/facebookincubator/create-react-app/issues/99#issuecomment-234657710) that CRA provides. That is to say you now "own" the configs. **No support** will be provided. Proceed with caution. | ||
|
||
## Installation | ||
|
||
Install the plugin from **npm**: | ||
|
||
```bash | ||
$ npm install craco --save-dev | ||
``` | ||
|
||
Create a `craco.config.js` file in the root directory: | ||
|
||
``` | ||
my-app | ||
├── node_modules | ||
├── craco.config.js | ||
└── package.json | ||
``` | ||
|
||
Export your configuration has as an **object literal**: | ||
|
||
```javascript | ||
/* craco.config.js */ | ||
|
||
module.exports = { | ||
... | ||
} | ||
``` | ||
|
||
or a **function**: | ||
|
||
```javascript | ||
/* craco.config.js */ | ||
|
||
module.exports = function({ env, paths }) { | ||
return { | ||
... | ||
}; | ||
} | ||
``` | ||
|
||
Update the existing calls to `react-scripts` in the `scripts` section of your `package.json` file to use the `craco` CLI: | ||
|
||
```diff | ||
/* package.json */ | ||
|
||
"scripts": { | ||
- "start": "react-scripts start", | ||
+ "start": "craco start", | ||
- "build": "react-scripts build", | ||
+ "build": "craco build" | ||
} | ||
``` | ||
|
||
Start your app for development: | ||
|
||
```bash | ||
$ npm start | ||
``` | ||
|
||
Or build your app: | ||
|
||
```bash | ||
$ npm run build | ||
``` | ||
|
||
## CLI Options | ||
|
||
When you execute `craco start` or `craco build` a few options are available... | ||
|
||
To change the location of the configuration file: | ||
|
||
```bash | ||
$ npm start craco --config config/my-cra-customized-config.js | ||
``` | ||
|
||
To use a custom version of the `react-scripts` packages with `craco`: | ||
|
||
```bash | ||
$ npm start craco --react-scripts react-scripts-ts | ||
``` | ||
|
||
To activate the **verbose** mode: | ||
|
||
```bash | ||
$ npm start craco --verbose | ||
``` | ||
|
||
## Configuration Overview | ||
|
||
When the property **mode** is available there are 2 possible values: | ||
- `extends`: the provided configuration will extends the CRA settings | ||
- `file`: the CRA settings will be reseted and you will provide an official configuration file for the plugin ([postcss](https://github.com/michael-ciniawsky/postcss-load-config#postcssrc), [eslint](https://eslint.org/docs/user-guide/configuring#configuration-file-formats)) that will supersede any settings. | ||
|
||
```javascript | ||
const { paths, when, whenDev, whenProd, ESLINT_MODES, POSTCSS_MODES } = require("craco"); | ||
|
||
module.exports = { | ||
style: { | ||
modules: { | ||
localIdentName: "" | ||
}, | ||
css: { | ||
loaderOptions: {} || (cssLoaderOptions, { env, paths }) => { return cssLoaderOptions; } | ||
}, | ||
sass: { | ||
loaderOptions: {} || (sassLoaderOptions, { env, paths }) => { return sassLoaderOptions; } | ||
}, | ||
postcss: { | ||
mode: "extends" || "file", | ||
plugins: [], | ||
loaderOptions: {} || (postcssLoaderOptions, { env, paths }) => { return postcssLoaderOptions; } | ||
} | ||
}, | ||
eslint: { | ||
enable: true, | ||
mode: "extends" || "file", | ||
formatter: "", | ||
globals: [], | ||
plugins: [], | ||
extends: [], | ||
rules: {}, | ||
loaderOptions: {} || (eslintOptions, { env, paths }) => { return eslintOptions; } | ||
}, | ||
webpack: { | ||
alias: {}, | ||
plugins: [] | ||
}, | ||
configureWebpack: {} || (webpackConfig, { env, paths }) => { return webpackConfig; }, | ||
devServer: {}, | ||
babel: { | ||
presets: [], | ||
plugins: [], | ||
loaderOptions: {} || (babelLoaderOptions, { env, paths }) => { return babelLoaderOptions; } | ||
}, | ||
plugins: [ | ||
{ | ||
plugin: { | ||
overrideCracoConfig: ({ cracoConfig, pluginOptions, context: { env, paths } }) => { return cracoConfig; }, | ||
overrideWebpackConfig: ({ webpackConfig, cracoConfig, pluginOptions, context: { env, paths } }) => { return webpackConfig; }, | ||
}, | ||
options: {} | ||
} | ||
] | ||
}; | ||
``` | ||
|
||
## Documentation | ||
|
||
Coming soon... | ||
|
||
## Develop a plugin | ||
|
||
## Acknowledgements | ||
|
||
[@timarney](https://github.com/timarney) for having created [react-app-rewired](https://github.com/timarney/react-app-rewired). | ||
|
||
## License | ||
|
||
Create React App Config Override is open source software [licensed as MIT](https://github.com/facebook/create-react-app/blob/master/LICENSE). |
Oops, something went wrong.