Build configuration plugins
Last updated
Was this helpful?
Last updated
Was this helpful?
ScandiPWA introduces concept of "build plugins". This is a feature of .
Define an empty object as a value of the scandipwa.build
field in your extension's package.json
Populate the configuration object with cracoPlugins
field, set it to empty array.
Create a new folder in your extension's root, name it build-config
:
Create a new file in it, name it to represent it's build modification purpose
Populate an array of cracoPlugins
in your package.json
with a path to your new file (relative to the extension root).
Inside of your plugin file, define a module.exports
equal to an object. This object may have two keys:
plugin
(required) where the plugin implementation will be defined
options
(optional) where the plugin options will be defined
Implement a plugin in the object created at the step 3). To do it, follow .
Define an empty object as a value of the scandipwa.build
field in your extension's package.json
Populate the configuration object with before
field, set it to empty string.
Create a new folder in your extension's root, name it build-config
:
Create a new file in it, name it to represent before-run script's purpose
Set the before
field in your package.json
equal to a path to your new file (relative to the extension root).
Inside of your plugin file, define a module.exports
equal to a function.
Implement a script based on your needs. No guidelines here, it's up to you!
Each plugin is an object, which might contain following keys (you can combine them):
overrideCracoConfig
- allows to customize the Craco configuration object.
overrideWebpackConfig
- allows to customize the Webpack config.
overrideDevServerConfig
- allows to customize the Webpack dev-server config
The values of this object keys are functions, which implement an override for the configuration. The function may be asynchronous.
The function overrideCracoConfig
allows a plugin override the configuration object before it's process by Craco.
The function must return a valid Craco configuration object. The function will be called with a single object argument having the following structure:
The function overrideWebpackConfig
allows plugin override the Webpack configuration object after it's been customized by Craco.
The function must return a valid Webpack configuration object. The function will be called with a single object argument having the following structure:
The function overrideDevServerConfig
let a plugin override the dev server config object after it's been customized by Craco.
The function must return a valid Webpack dev-server configuration object. The function will be called with a single object argument having the following structure:
We used getLoader
and loaderByName
utility functions of Craco. Learn more about them in .
The plugin syntax of Create ScandiPWA App is based on the (Create React App Configuration Override) plugin syntax.