React-app-rewired: Changing the build path to lib doesnt work

Created on 20 Feb 2020  路  3Comments  路  Source: timarney/react-app-rewired

Changing the target build path to lib is throwing an exception. Below is the config-overrides.js:

const path = require('path');

config.output = {
    path: path.resolve(__dirname, 'lib'),
    libraryTarget: 'umd',
  };

package.json

"build": "react-app-rewired build",

lib folder created but is throwing an exception, and is looking for main.js at build folder, rather than looking at lib folder:

no such file or directory buildmain.js'

Most helpful comment

Try using the paths config as documented in the readme.

module.exports = {
  webpack: function(config, env) {
    // your normal config-overrides.js overrides
    return config;
  },
  // The paths config to use when compiling your react app
  //  for development or production.
  paths: function(paths, env) {
    // ...add your paths config
    paths.appBuild = path.resolve(__dirname, 'lib');
    return paths;
  }
}

See create-react-app config/paths for the list of path variables - the one you would want to change is the paths.appBuild path.

If that doesn't work, try the alternative method documented here.

All 3 comments

the same, Is there any solution?

Try using the paths config as documented in the readme.

module.exports = {
  webpack: function(config, env) {
    // your normal config-overrides.js overrides
    return config;
  },
  // The paths config to use when compiling your react app
  //  for development or production.
  paths: function(paths, env) {
    // ...add your paths config
    paths.appBuild = path.resolve(__dirname, 'lib');
    return paths;
  }
}

See create-react-app config/paths for the list of path variables - the one you would want to change is the paths.appBuild path.

If that doesn't work, try the alternative method documented here.

@dawnmist thank you so much! lifesaver!

Was this page helpful?
0 / 5 - 0 ratings