Skip to content

Make loader paths extensible via .env file #1346

Closed
@christiantinauer

Description

@christiantinauer

Hi,

first of all thank you for this app. It makes developing react apps a lot easier. What I now want to achieve is separating some controls/modules from my app and keep them in a different folder (outside of src). The problem is that css and babel loader ignore all files outside of src (and symlinks are resolved).

The idea is to make the loader paths extensible via the .env file (quite similar to NODE_PATH variable)

ADDITIONAL_APP_SOURCES=..\controls-app1\src;..\controls-app2\src

and adapt path.js

var appSrcs = (process.env.ADDITIONAL_APP_SOURCES || '')
  .split(process.platform === 'win32' ? ';' : ':')
  .filter(Boolean)
  .filter(folder => !path.isAbsolute(folder))
  .concat(['src'])
  .map(resolveApp);

...

module.exports = {
  appBuild: resolveApp('build'),
  appPublic: resolveApp('public'),
  appHtml: resolveApp('public/index.html'),
  appIndexJs: resolveApp('src/index.js'),
  appPackageJson: resolveApp('package.json'),
  appSrc: appSrcs,
  yarnLockFile: resolveApp('yarn.lock'),
  testsSetup: resolveApp('src/setupTests.js'),
  appNodeModules: resolveApp('node_modules'),
  // this is empty with npm3 but node resolution searches higher anyway:
  ownNodeModules: resolveOwn('../node_modules'),
  nodePaths: nodePaths
};

Is this a good idea? Am I missing something?

With kind regards,

Christian

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