How to use the customize-cra.babelInclude function in customize-cra

To help you get started, we’ve selected a few customize-cra 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 spaxjs / spax / examples / demo-simple / config-overrides.js View on Github external
const { override, babelInclude, addWebpackAlias } = require("customize-cra");

const resolve = (...dest) => {
  return path.resolve(__dirname, ...dest);
};

const getAliasForCommonLibraries = (modules) => {
  return modules.reduce((obj, name) => {
    return Object.assign(obj, {
      [name]: resolve("node_modules", name),
    });
  }, {});
};

module.exports = override(
  babelInclude([
    resolve("src"), // make sure you link your own source
    // resolve("node_modules", "@spax"),
  ]),
  addWebpackAlias(getAliasForCommonLibraries([
    "react",
    "react-dom",
    "react-hot-loader",
    "react-router-dom",
    "@material-ui/core",
    "@material-ui/icons",
    "@types/node",
    "@types/react",
    "@types/react-dom",
    "@types/react-router-dom"
  ])),
);
github quid / refraction / config-overrides.js View on Github external
config.resolve.plugins = config.resolve.plugins.filter(
    p => p.constructor.name !== 'ModuleScopePlugin'
  );
  return config;
};

/**
 * react-app-rewired configuration file
 *
 * Theses functions are used to override the configurations provided by
 * create-react-app to be able to tweak it without ejecting the
 * project. Be careful!
 */
module.exports = {
  webpack: override(
    babelInclude([path.resolve('src'), path.resolve('packages')]),
    useEslintRc(),
    removeModuleScopePlugin(),
    addWebpackAlias(lernaAlias.webpack())
  ),
  jest: config => {
    // create-react-app looks for tests in `src`, we look in `packages`
    config.roots = ['/packages'];
    config.testMatch = config.testMatch.map(m => m.replace('src', 'packages'));
    config.collectCoverageFrom = ['**/packages/**/*.js'];
    config.coveragePathIgnorePatterns = ['/dist/'];

    // we tell Jest to import the @quid packages from their source directory
    // rather than from the dist one, so we don't have to build them each time
    config.moduleNameMapper = lernaAlias.jest();

    return config;
github ctrlplusb / cra-monorepo / frontend / config-overrides.js View on Github external
disableEsLint,
  override,
} = require('customize-cra');
// TODO: Replace with official plugin when it is supported
const ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin');

module.exports = override(
  // Add support for React Fast Refresh
  process.env.NODE_ENV === 'development'
    ? addBabelPlugin('react-refresh/babel')
    : undefined,
  process.env.NODE_ENV === 'development'
    ? addWebpackPlugin(new ReactRefreshPlugin())
    : undefined,
  // Add support for transpiling local package imports
  babelInclude([
    path.resolve('src'),
    path.resolve('../backend'),
    path.resolve('../universal'),
  ]),
  babelExclude([
    path.resolve('../backend/node_modules'),
    path.resolve('../universal/node_modules'),
  ]),
  // Disable CRA lint in favour of project lint
  disableEsLint(),
);
github dotnetcore / WTM / demo / WalkingTec.Mvvm.Next / ClientApp / packages / www-react / config-overrides.js View on Github external
const { override, fixBabelImports, addBundleVisualizer, addLessLoader, disableEsLint, babelInclude, addWebpackResolve } = require('customize-cra');
const path = require('path');
module.exports = override(
    // 模块 解析 路径
    // addWebpackResolve({
    //     modules: [
    //         path.resolve(path.dirname(path.dirname(process.cwd())), 'node_modules'),
    //         path.resolve(process.cwd(), 'node_modules'),
    //         path.resolve(process.cwd(), 'src'),
    //     ]
    // }),
    // 添加 需要 编译的目录
    babelInclude([
        // 当前项目
        path.resolve(process.cwd(), 'src'),
        // public 目录
        path.resolve(path.dirname(process.cwd()), 'public', 'src')
    ]),
    // 按需加载
    fixBabelImports('import', {
        libraryName: 'antd',
        libraryDirectory: 'es',
        style: true,
    }),
    addLessLoader({
        javascriptEnabled: true,
        //    modifyVars: { '@primary-color': '#1DA57A' },
        localIdentName: "leng-[local]-[hash:base64:5]"
    }),
github pennlabs / penn-courses / frontend / plan-old / config-overrides.js View on Github external
const getYarnWorkspaces = require('get-yarn-workspaces');
const { override, babelInclude } = require('customize-cra');

module.exports = override(
  babelInclude(getYarnWorkspaces())
);
github ian13456 / mine.js / config-overrides.js View on Github external
addWebpackAlias
} = require('customize-cra')

module.exports = override(
  (() => config => {
    config.module.rules.push({
      test: /\.worker\.js$/,
      use: { loader: 'worker-loader', options: { inline: true } }
    })

    config.output.globalObject = 'this'

    return config
  })(),
  removeModuleScopePlugin(),
  babelInclude([path.resolve(__dirname, 'src'), path.resolve(__dirname, 'core')]),
  addWebpackAlias({
    ['core']: path.resolve(__dirname, 'core')
  })
)
github kitze / JSUI / config-overrides.js View on Github external
module.exports = (config, env) => {
  config = override(
    enableEslintIgnore(),
    ...addBabelPlugins(
      'babel-plugin-emotion',
      'babel-plugin-preval',
      'babel-plugin-transform-do-expressions'
    ),
    addDecoratorsLegacy(),
    babelInclude([resolveApp('src')])
  )(config);

  config.target = 'electron-renderer';
  config = rewireReactHotLoader(config, env);
  return config;
};
github react-native-elements / react-native-elements-app / config-overrides.js View on Github external
const eslintRuleOptions = config.module.rules.filter(
    r => r.use && r.use.some(u => u.options && u.options.useEslintrc !== void 0)
  )[0].use[0].options;
  if(!Array.isArray(eslintRuleOptions.globals)) eslintRuleOptions.globals = [];
  eslintRuleOptions.globals = [...eslintRuleOptions.globals, ...Object.keys(vars)];

  return config;
};

module.exports = override(
  removeModuleScopePlugin(),
  registerGlobals({
    __DEV__: (process.env.NODE_ENV === "development")
  }),
  babelInclude([
    path.resolve("src"),
    path.resolve(modulesPath, "react-native-elements"),
    path.resolve(modulesPath, "react-native-ratings"),
    path.resolve(modulesPath, "react-native-status-bar-height"),
    path.resolve(modulesPath, "react-native-vector-icons"),
    path.resolve(modulesPath, "react-native-safe-area-view"),
    path.resolve(modulesPath, "react-navigation"),
    path.resolve(modulesPath, "react-native-tab-view"),
    path.resolve(modulesPath, "react-native-touchable-scale"),
    path.resolve(modulesPath, "expo-linear-gradient"),
    path.resolve(modulesPath, "@react-navigation", "native"),
    path.resolve(modulesPath, "react-native-gesture-handler-web"),
  ]),
  addBabelPlugins(
    "@babel/plugin-proposal-class-properties",
  ),