Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add info on how to extend webpack.config.js #14590

merged 2 commits into from Mar 25, 2019
Changes from all commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+24 −0
Diff settings


Just for now

@@ -287,4 +287,28 @@ Should there be any situation where you want to provide your own webpack config,
* the command receives a `--config` argument. Example: `wp-scripts build --config my-own-webpack-config.js`.
* there is a file called `webpack.config.js` or `webpack.config.babel.js` in the top-level directory of your package (at the same level than your `package.json`).

##### Extending the webpack config

To extend the provided webpack config, or replace subsections within the provided webpack config, you can provide your own `webpack.config.js` file, `require` the provided `webpack.config.js` file, and use the [`spread` operator]( to import all of or part of the provided configuration.

In the example below, a `webpack.config.js` file is added to the root folder extending the provided webpack config to include [`@svgr/webpack`]( and [`url-loader`](

const defaultConfig = require("./node_modules/@wordpress/scripts/config/webpack.config");
module.exports = {
module: {
rules: [
test: /\.svg$/,
use: ["@svgr/webpack", "url-loader"]
If you follow this approach, please, be aware that future versions of this package may change what webpack and Babel plugins we bundle, default configs, etc. Should those changes be necessary, they will be registered in the [package's CHANGELOG](, so make sure to read it before upgrading.
<br/><br/><p align="center"><img src="" alt="Code is Poetry." /></p>
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.