fix build
This commit is contained in:
parent
5f9cca9289
commit
5f37b48864
1 changed files with 18 additions and 15 deletions
|
@ -1,16 +1,16 @@
|
||||||
'use strict';
|
"use strict";
|
||||||
|
|
||||||
const fs = require('fs');
|
const fs = require("fs");
|
||||||
const path = require('path');
|
const path = require("path");
|
||||||
const paths = require('./paths');
|
const paths = require("./paths");
|
||||||
|
|
||||||
// Make sure that including paths.js after env.js will read .env variables.
|
// Make sure that including paths.js after env.js will read .env variables.
|
||||||
delete require.cache[require.resolve('./paths')];
|
delete require.cache[require.resolve("./paths")];
|
||||||
|
|
||||||
const NODE_ENV = process.env.NODE_ENV;
|
const NODE_ENV = process.env.NODE_ENV;
|
||||||
if (!NODE_ENV) {
|
if (!NODE_ENV) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'The NODE_ENV environment variable is required but was not specified.'
|
"The NODE_ENV environment variable is required but was not specified."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@ const dotenvFiles = [
|
||||||
// Don't include `.env.local` for `test` environment
|
// Don't include `.env.local` for `test` environment
|
||||||
// since normally you expect tests to produce the same
|
// since normally you expect tests to produce the same
|
||||||
// results for everyone
|
// results for everyone
|
||||||
NODE_ENV !== 'test' && `${paths.dotenv}.local`,
|
NODE_ENV !== "test" && `${paths.dotenv}.local`,
|
||||||
paths.dotenv,
|
paths.dotenv
|
||||||
].filter(Boolean);
|
].filter(Boolean);
|
||||||
|
|
||||||
// Load environment variables from .env* files. Suppress warnings using silent
|
// Load environment variables from .env* files. Suppress warnings using silent
|
||||||
|
@ -32,9 +32,9 @@ const dotenvFiles = [
|
||||||
// https://github.com/motdotla/dotenv-expand
|
// https://github.com/motdotla/dotenv-expand
|
||||||
dotenvFiles.forEach(dotenvFile => {
|
dotenvFiles.forEach(dotenvFile => {
|
||||||
if (fs.existsSync(dotenvFile)) {
|
if (fs.existsSync(dotenvFile)) {
|
||||||
require('dotenv-expand')(
|
require("dotenv-expand")(
|
||||||
require('dotenv').config({
|
require("dotenv").config({
|
||||||
path: dotenvFile,
|
path: dotenvFile
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ dotenvFiles.forEach(dotenvFile => {
|
||||||
// https://github.com/facebook/create-react-app/issues/1023#issuecomment-265344421
|
// https://github.com/facebook/create-react-app/issues/1023#issuecomment-265344421
|
||||||
// We also resolve them to make sure all tools using them work consistently.
|
// We also resolve them to make sure all tools using them work consistently.
|
||||||
const appDirectory = fs.realpathSync(process.cwd());
|
const appDirectory = fs.realpathSync(process.cwd());
|
||||||
process.env.NODE_PATH = (process.env.NODE_PATH || '')
|
process.env.NODE_PATH = (process.env.NODE_PATH || "")
|
||||||
.split(path.delimiter)
|
.split(path.delimiter)
|
||||||
.filter(folder => folder && !path.isAbsolute(folder))
|
.filter(folder => folder && !path.isAbsolute(folder))
|
||||||
.map(folder => path.resolve(appDirectory, folder))
|
.map(folder => path.resolve(appDirectory, folder))
|
||||||
|
@ -71,20 +71,23 @@ function getClientEnvironment(publicUrl) {
|
||||||
{
|
{
|
||||||
// Useful for determining whether we’re running in production mode.
|
// Useful for determining whether we’re running in production mode.
|
||||||
// Most importantly, it switches React into the correct mode.
|
// Most importantly, it switches React into the correct mode.
|
||||||
NODE_ENV: process.env.NODE_ENV || 'development',
|
NODE_ENV: process.env.NODE_ENV || "development",
|
||||||
// Useful for resolving the correct path to static assets in `public`.
|
// Useful for resolving the correct path to static assets in `public`.
|
||||||
// For example, <img src={process.env.PUBLIC_URL + '/img/logo.png'} />.
|
// For example, <img src={process.env.PUBLIC_URL + '/img/logo.png'} />.
|
||||||
// This should only be used as an escape hatch. Normally you would put
|
// This should only be used as an escape hatch. Normally you would put
|
||||||
// images into the `src` and `import` them in code to get their paths.
|
// images into the `src` and `import` them in code to get their paths.
|
||||||
PUBLIC_URL: publicUrl,
|
PUBLIC_URL: publicUrl,
|
||||||
|
// This is a bodge.
|
||||||
|
// See https://github.com/bunkat/later/issues/155
|
||||||
|
LATER_COV: false
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
// Stringify all values so we can feed into Webpack DefinePlugin
|
// Stringify all values so we can feed into Webpack DefinePlugin
|
||||||
const stringified = {
|
const stringified = {
|
||||||
'process.env': Object.keys(raw).reduce((env, key) => {
|
"process.env": Object.keys(raw).reduce((env, key) => {
|
||||||
env[key] = JSON.stringify(raw[key]);
|
env[key] = JSON.stringify(raw[key]);
|
||||||
return env;
|
return env;
|
||||||
}, {}),
|
}, {})
|
||||||
};
|
};
|
||||||
|
|
||||||
return { raw, stringified };
|
return { raw, stringified };
|
||||||
|
|
Loading…
Reference in a new issue