How to use the @craco/craco.getLoaders function in @craco/craco

To help you get started, we’ve selected a few @craco/craco examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github preconstruct / preconstruct / packages / craco / index.js View on Github external
overrideWebpackConfig: ({ webpackConfig }) => {
    // Search for all instances of babel-loader.
    const { hasFoundAny, matches } = getLoaders(
      webpackConfig,
      loaderByName("babel-loader")
    );

    // If we can't find the loader then throw an error.
    if (!hasFoundAny) {
      throw new Error("could not find babel-loader");
    }

    let hasFoundRightLoader = false;

    // Loop through each match, enabling babelrc and clearing any presets.
    matches.forEach(({ loader }) => {
      if (loader.test.toString() === /\.(js|mjs|jsx|ts|tsx)$/.toString()) {
        hasFoundRightLoader = true;
        if (!loader.options) {

@craco/craco

Create React App Configuration Override, an easy and comprehensible configuration layer for create-react-app.

Apache-2.0
Latest version published 1 year ago

Package Health Score

68 / 100
Full package analysis