Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/webdeveric/craco-plugin
Create your own CRACO plugins
https://github.com/webdeveric/craco-plugin
craco craco-plugin create-react-app
Last synced: 3 days ago
JSON representation
Create your own CRACO plugins
- Host: GitHub
- URL: https://github.com/webdeveric/craco-plugin
- Owner: webdeveric
- Created: 2021-05-16T23:47:13.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-04-10T17:59:09.000Z (over 1 year ago)
- Last Synced: 2024-10-11T23:11:39.843Z (about 1 month ago)
- Topics: craco, craco-plugin, create-react-app
- Language: TypeScript
- Homepage:
- Size: 4.36 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# @webdeveric/craco-plugin
## Install
```shell
npm install @webdeveric/craco-plugin --save
```## Usage
```js
const { createCracoPlugin } = require('@webdeveric/craco-plugin');const myCracoPlugin = createCracoPlugin({
// Used in verbose logging.
name: 'My Plugin',
/**
* Provide default values for all of your options.
*/
getOptions(options, context) {
return {
// Default option values go here.
// Tou can use `context.env` to conditionally set values based on the NODE_ENV.
...options,
};
},
/*
* These arrays should contain functions that modify the provided configuration object.
* At lease one of the arrays should be provided.
*
* You can directly modify the `config` or you can return a new object.
* The return value of this function will be the `config` parameter for
* the next function in this array. If you don't return a value, this
* `config` object will be used for the next function's `config` parameter.
*
* Each function can take 4 parameters
* - config (one of: cracoConfig, webpackConfig, devServerConfig, jestConfig)
* - pluginOptions
* - context
* - cracoConfig
*/
craco = [
(config, pluginOptions, context, cracoConfig) => config,
],
webpack = [
(webpackConfig, pluginOptions, context, cracoConfig) => webpackConfig,
],
devServer = [
(devServerConfig, pluginOptions, context, cracoConfig) => devServerConfig,
],
jest = [
(jestConfig, pluginOptions, context, cracoConfig) => jestConfig,
],
});
```