How to use the @craco/craco.getLoader 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 guandjoy / redfish / src / react-app / craco.config.js View on Github external
configure: (webpackConfig) => {
      const lm = getLoader(webpackConfig, loaderByName('babel-loader'));
      const loader = lm.match.loader;
      webpackConfig.module.rules[2].oneOf[1] = transformBabelLoader(loader);
      return webpackConfig;
    }
  }
github DocSpring / craco-less / lib / craco-less.js View on Github external
}
      });
    } else {
      throwError(
        `Found an unhandled loader in the ${context.env} webpack config: ${rule.loader}`,
        "webpack+unknown+rule"
      );
    }
  });

  if (pluginOptions.modifyLessRule) {
    lessRule = pluginOptions.modifyLessRule(lessRule, context);
  }
  oneOfRule.oneOf.push(lessRule);

  const { isFound, match: fileLoaderMatch } = getLoader(
    webpackConfig,
    loaderByName("file-loader")
  );
  if (!isFound) {
    throwError(
      `Can't find file-loader in the ${context.env} webpack config!`,
      "webpack+file-loader"
    );
  }
  fileLoaderMatch.loader.exclude.push(lessExtension);

  return webpackConfig;
};
github jedmao / craco-linaria / src / index.js View on Github external
const throwError = (message, githubIssueQuery) =>
		throwUnexpectedConfigError({
			packageName: 'craco-linaria',
			githubRepo: 'jedmao/craco-linaria',
			message,
			githubIssueQuery,
		})

	if (!webpackConfig.module) {
		throwError(
			`Can't find 'module' key in the ${context.env} webpack config!`,
			'webpack+module',
		)
	}

	const { isFound, match: babelLoaderMatch } = getLoader(
		webpackConfig,
		loaderByName('babel-loader'),
	)

	if (!isFound) {
		throwError(
			`Can't find babel-loader in the ${context.env} webpack config!`,
			'webpack+babel-loader',
		)
	}

	const oneOfRules = webpackConfig.module.rules.find(rule => rule.oneOf)
	if (!oneOfRules) {
		throwError(
			`Can't find 'oneOf' rules under module.rules in the ${context.env} webpack config!`,
			'webpack+rules+oneOf',
github Lattice-Automation / seqviz / demo / craco.config.js View on Github external
overrideWebpackConfig: ({ context, webpackConfig }) => {
          const { isFound, match: fileLoaderMatch } = getLoader(
            webpackConfig,
            loaderByName("file-loader")
          );

          if (!isFound) {
            throwUnexpectedConfigError({
              message: `Can't find file-loader in the ${context.env} webpack config!`
            });
          }

          fileLoaderMatch.loader.exclude.push(/theme.config$/);
          fileLoaderMatch.loader.exclude.push(/\.variables$/);
          fileLoaderMatch.loader.exclude.push(/\.overrides$/);

          return webpackConfig;
        }

@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