Skip to content

Support src directory as webpack resolve.modules #3596

Closed
@haraldrudell

Description

@haraldrudell

Much code that is pasted into Create React App assumes that the src directory is resolved so that filename and module references becomes the same.

people want to write
import 'components/Accordion'
instead of
import './components/Accordion'
because then at some point, components could be a module.
Drawback is that the thing won’t run no more unless using webpack resolver.

The suggestion is to modify webpack.config.js and such to:

  resolve: {
    modules: [
      path.resolve('src'),
      path.resolve('module_override'),
      'node_modules', .

(using the paths object, obviously)

from:

  resolve: {
    // This allows you to set a fallback for where Webpack should look for modules.
    // We placed these paths second because we want `node_modules` to "win"
    // if there are any conflicts. This matches Node resolution mechanism.
    // https://github.com/facebookincubator/create-react-app/issues/253
    modules: ['node_modules', paths.appNodeModules].concat(

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions