Created by: dceddia
(This is related to issue #670 (closed))
This commit adds a "plugins" module and integrates it into the dev and prod build scripts.
The design and functionality is intentionally minimal, but it allows a user to write a plugin or series of plugins to manipulate the Webpack config as necessary. The example given in the plugins.js
file shows a plugin that adds a SASS loader:
module.exports = function(webpackConfig) {
webpackConfig.module.loaders.push({
test: /\.scss$/,
loaders: ["style", "css", "sass"]
});
return webpackConfig;
};
But conceivably any sort of Webpack config transformation could be done here.
Plugins are loaded and run, in order, from the plugins
key in package.json
. This would load a module named cra-plugin-sass
, which would need to be npm install
'd separately.
"plugins": [
"cra-plugin-sass"
]
We could also explore auto-discovery of plugins ala Babel or Karma, by searching for packages matching the "cra-plugin-*" prefix. However, the loading order does matter (since the config is transformed by every plugin in turn) and an array of plugins is more explicit.