devowlio / wp-react-starter

🚀WordPress Plugin Boilerplate using modern web techs like TypeScript, SASS, and so on... on top of a local development environment with Docker and predefined GitLab CI for continous integration and deployment!
https://devowl.io/wp-react-starter/
Other
387 stars 51 forks source link

Example of extending the webpack config #24

Closed fedorenkodev closed 4 years ago

fedorenkodev commented 4 years ago

Hey guys, Could anybody please provide an example of extending the webpack config? Especially how to add the new plugin. Thanks.

matzeeable commented 4 years ago

Hi @fedorenkodev !

Thanks for your question! Did you checkout the API here: https://devowlio.gitbook.io/wp-react-starter/advanced/extend-compose-webpack#webpack ?

If you want to add another plugin, you can do something like this:

import { createDefaultSettings } from "../../../common/webpack.factory";
import { BundleAnalyzerPlugin } from "webpack-bundle-analyzer";

export default createDefaultSettings("plugin", {
    override: ([config]) => {
        config.plugins.push(
            new BundleAnalyzerPlugin()
        );
    }
});

Regards, Matthew 😎

fedorenkodev commented 4 years ago

Looks good to me, just wanted to clarify if its the correct way to use the push method. Thanks!