How to use the customize-cra.addWebpackAlias 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 kalmhq / kalm / frontend / config-overrides.js View on Github external
? addWebpackPlugin(
        // https://docs.sentry.io/platforms/javascript/guides/react/sourcemaps/
        new SentryWebpackPlugin({
          // sentry-cli configuration
          authToken: process.env.SENTRY_AUTH_TOKEN,
          org: process.env.SENTRY_ORG,
          project: process.env.SENTRY_PROJECT,
          release: process.env.REACT_APP_NAME + "@" + process.env.REACT_APP_VERSION,

          // webpack specific configuration
          include: ".",
          ignore: ["node_modules", "webpack.config.js"],
        }),
      )
    : undefined,
  addWebpackAlias({
    "@apiType": resolve(
      `src/api/${
        process.env.REACT_APP_USE_MOCK_API === "true" || process.env.NODE_ENV === "test" ? "mockApi" : "realApi"
      }`,
    ),
  }),
  // addWebpackPlugin(new BundleAnalyzerPlugin()),
);
github quid / refraction / config-overrides.js View on Github external
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 ggoodman / velcro / packages / playground / config-overrides.js View on Github external
//@ts-check
'use strict';

const { addWebpackPlugin, override, useBabelRc, addWebpackAlias } = require('customize-cra');
const MonacoEditorWebpackPlugin = require('monaco-editor-webpack-plugin');
const WorkerPlugin = require('worker-plugin');

module.exports = override(
  addWebpackPlugin(new MonacoEditorWebpackPlugin()),
  addWebpackPlugin(new WorkerPlugin()),
  useBabelRc(),
  addWebpackAlias({
    '@velcro/bundler': '@velcro/bundler/dist/dist-module/index.js',
    '@velcro/resolver-host-compound': '@velcro/resolver-host-compound/dist/dist-module/index.js',
    '@velcro/resolver-host-unpkg': '@velcro/resolver-host-unpkg/dist/dist-module/index.js',
    '@velcro/resolver': '@velcro/resolver/dist/dist-module/index.js',
  })
);
github LANIF-UI / dva-boot-admin / config-overrides.js View on Github external
override,
  addDecoratorsLegacy,
  disableEsLint,
  addBundleVisualizer,
  addWebpackAlias,
  adjustWorkbox,
  addLessLoader,
  fixBabelImports
} = require('customize-cra');
const path = require('path');

module.exports = override(
  addDecoratorsLegacy(),
  disableEsLint(),
  addBundleVisualizer({}, true),
  addWebpackAlias({
    '@': path.resolve(__dirname, 'src'),
    components: path.resolve(__dirname, 'src/components'),
    assets: path.resolve(__dirname, 'src/assets')
  }),
  adjustWorkbox(wb =>
    Object.assign(wb, {
      skipWaiting: true,
      exclude: (wb.exclude || []).concat('index.html')
    })
  ),
  fixBabelImports('import', {
    libraryName: 'antd',
    style: true
  }),
  addLessLoader({
    localIdentName: '[local]--[hash:base64:8]',
github ian13456 / mine.js / config-overrides.js View on Github external
} = 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 ghondar / crassa / config-overrides.js View on Github external
const addLoadablePlugin =  config => {
  config.plugins.push(
    new LoadablePlugin()
  )

  config.plugins[0].options.inject = false

  return config
}

module.exports = override(
  process.env.NODE_ENV === 'production' && addLoadablePlugin,
  disableEsLint(),
  ...addBabelPlugins('transform-imports', '@loadable/babel-plugin', 'transform-react-remove-prop-types'),
  addWebpackAlias({ ...aliases, 'lodash-es': 'lodash' }),
  hasCustomConfigOverrides && require(appConfigOverrides)
)
github hyanmandian / react-etalpreliob / config-overrides.js View on Github external
const path = require("path");
const {
  override,
  addWebpackAlias,
  addBabelPlugins,
  addBundleVisualizer
} = require("customize-cra");

module.exports = {
  webpack: override(
    addWebpackAlias({
      "#": path.resolve(__dirname, "./src"),
      "react-dom": "@hot-loader/react-dom"
    }),
    addBundleVisualizer({}, true),
    ...addBabelPlugins("emotion", "react-hot-loader/babel")
  ),
  jest: config => ({
    ...config,
    setupFilesAfterEnv: ["/.jest/setup.js"],
    moduleNameMapper: { "#(.*)$": "/src/$1" },
    coverageDirectory: "/.coverage"
  })
};
github otofu-square / realworld-react-redux / config-overrides.js View on Github external
const { override, addWebpackAlias } = require("customize-cra");
const path = require("path");

module.exports = override(
  addWebpackAlias({
    "@": path.resolve(__dirname, "./src")
  })
);
github LANIF-UI / dva-boot / config-overrides.js View on Github external
override,
  addDecoratorsLegacy,
  disableEsLint,
  addBundleVisualizer,
  addWebpackAlias,
  adjustWorkbox,
  addLessLoader,
  fixBabelImports
} = require('customize-cra');
const path = require('path');

module.exports = override(
  addDecoratorsLegacy(),
  disableEsLint(),
  process.env.BUNDLE_VISUALIZE === 1 && addBundleVisualizer(),
  addWebpackAlias({
    '@': path.resolve(__dirname, 'src'),
    components: path.resolve(__dirname, 'src/components'),
    assets: path.resolve(__dirname, 'src/assets')
  }),
  adjustWorkbox(wb =>
    Object.assign(wb, {
      skipWaiting: true,
      exclude: (wb.exclude || []).concat('index.html')
    })
  ),
  fixBabelImports('import', {
    libraryName: 'antd',
    style: true
  }),
  addLessLoader({
    localIdentName: '[local]--[hash:base64:8]',
github liuguanhua / react-cnode-project / config-overrides.js View on Github external
module.exports = {
  webpack: override(
    fixBabelImports('import', {
      libraryName: 'antd',
      libraryDirectory: 'es',
      style: 'css',
      style: true
    }),
    addLessLoader({
      javascriptEnabled: true,
      modifyVars: {
        '@primary-color': '#639'
      }
    }),
    addWebpackAlias({
      '@': resolveApp('src'),
      '@module': resolveApp('node_modules'),
      '@assets': resolveApp('src/assets'),
      '@images': resolveApp('src/assets/images'),
      '@fonts': resolveApp('src/assets/fonts'),
      '@view': resolveApp('src/view'),
      '@store': resolveApp('src/store'),
      '@component': resolveApp('src/component'),
      '@script': resolveApp('src/script')
    }),
    config => {
      //自定义svg loader方式
      const len = config.module.rules[2].oneOf.length
      config.module.rules[2].oneOf[1].options.plugins.shift()
      config.module.rules[2].oneOf[len - 1].exclude.push(/\.svg$/)
      config.module.rules[2].oneOf.push({