React-app-rewired: Help, How to add webpack alias ?

Created on 12 Dec 2017  路  4Comments  路  Source: timarney/react-app-rewired

I want to add custom alias , how i do it ?

Most helpful comment

If I've understood the Webpack Config and Webpack Resolve documentation correctly, you'd need to add a resolve section to the config in your config-overrides.js file:

module.exports = function override(config, env) {
  config.resolve = {
    alias: {
      Utilities: path.resolve(__dirname, 'src/utilities/'),
      Templates: path.resolve(__dirname, 'src/templates/')
    }
  };
  return config; 
}

All 4 comments

If I've understood the Webpack Config and Webpack Resolve documentation correctly, you'd need to add a resolve section to the config in your config-overrides.js file:

module.exports = function override(config, env) {
  config.resolve = {
    alias: {
      Utilities: path.resolve(__dirname, 'src/utilities/'),
      Templates: path.resolve(__dirname, 'src/templates/')
    }
  };
  return config; 
}

how to add modules like this:

{
  test: /\.module\.less$/,
  loader: ExtractTextPlugin.extract(
    'css?sourceMap&modules&localIdentName=[local]___[hash:base64:5]!!' +
    'postcss!' +
    `less-loader?{"sourceMap":true,"modifyVars":${JSON.stringify(theme)}}`
  ),
}

I just want to use less.modifyVars to change my own theme color.

@Duobe have you tried using react-app-rewire-less? It does the Less setup for you.

I don't use less but I see other using modifyVars in this issue https://github.com/timarney/react-app-rewired/issues/132

@timarney Thanks ! #132 is worked.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lyudad picture lyudad  路  6Comments

zhihongzhong picture zhihongzhong  路  4Comments

bilthon picture bilthon  路  5Comments

huygn picture huygn  路  3Comments

artalar picture artalar  路  4Comments