question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Static config file at project root post 1.0.0

See original GitHub issue

Creating a new issue as I can’t reopen https://github.com/facebookincubator/create-react-app/issues/1469

With the 1.0 updates stopping any files outside src working, where is the correct place to have static config files?

My previous solution (seen below) of having a config folder at the project root doesn’t work. Not sure what the recommend solution is because it doesn’t feel right to pull a config folder inside src.

env files won’t provide the functionality I am after, as the config files include arrays/objects.

const merge = require('lodash/merge');
const global = require('./global');

var env; // let doesn't seem to work here
if (process.env.NODE_ENV === 'development') {
    env = require('./development');
} else {
    env = require('./production');
}

module.exports = merge(global, env);

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
gaearoncommented, Jun 22, 2017

My previous solution (seen below) of having a config folder at the project root doesn’t work. Not sure what the recommend solution is because it doesn’t feel right to pull a config folder inside src.

That’s the recommended solution, if you need to import it, put it in src. This ensures it gets compiled.

0reactions
joshhornbycommented, Jun 27, 2017

Fair enough, doesn’t feel right that config should live inside src but guess it the easiest solution.

Thanks for the help @codedavinci

Read more comments on GitHub >

github_iconTop Results From Across the Web

Static config file at project root · Issue #1469 - GitHub
I want to have a config directory in the root of my project, and inside an index.js something like: import local from './local';...
Read more >
node.js - express.static() only works when run locally
static (__dirname + '/build')) should be serving all static files in my build folder, but it seems that in production it isn't working...
Read more >
Config Plugins - Expo Documentation
The compiler iterates over all of the mods and asynchronously evaluates them, providing some base props like the projectRoot . After each mod,...
Read more >
Create-react-app environments - Medium
React imports environment variables that are defined in a .env file at the root of the project. Skip to Environment Configuration if you're...
Read more >
Configuration Reference - Astro Documentation
Configuration Reference. The following reference covers all supported configuration options in Astro. To learn more about configuring Astro, read our guide ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found