fix build

This commit is contained in:
Marks Polakovs 2020-04-16 12:53:17 +02:00
parent 5f9cca9289
commit 5f37b48864

View file

@ -1,16 +1,16 @@
'use strict';
"use strict";
const fs = require('fs');
const path = require('path');
const paths = require('./paths');
const fs = require("fs");
const path = require("path");
const paths = require("./paths");
// 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;
if (!NODE_ENV) {
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
// since normally you expect tests to produce the same
// results for everyone
NODE_ENV !== 'test' && `${paths.dotenv}.local`,
paths.dotenv,
NODE_ENV !== "test" && `${paths.dotenv}.local`,
paths.dotenv
].filter(Boolean);
// Load environment variables from .env* files. Suppress warnings using silent
@ -32,9 +32,9 @@ const dotenvFiles = [
// https://github.com/motdotla/dotenv-expand
dotenvFiles.forEach(dotenvFile => {
if (fs.existsSync(dotenvFile)) {
require('dotenv-expand')(
require('dotenv').config({
path: dotenvFile,
require("dotenv-expand")(
require("dotenv").config({
path: dotenvFile
})
);
}
@ -50,7 +50,7 @@ dotenvFiles.forEach(dotenvFile => {
// https://github.com/facebook/create-react-app/issues/1023#issuecomment-265344421
// We also resolve them to make sure all tools using them work consistently.
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)
.filter(folder => folder && !path.isAbsolute(folder))
.map(folder => path.resolve(appDirectory, folder))
@ -71,20 +71,23 @@ function getClientEnvironment(publicUrl) {
{
// Useful for determining whether were running in production 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`.
// For example, <img src={process.env.PUBLIC_URL + '/img/logo.png'} />.
// 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.
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
const stringified = {
'process.env': Object.keys(raw).reduce((env, key) => {
"process.env": Object.keys(raw).reduce((env, key) => {
env[key] = JSON.stringify(raw[key]);
return env;
}, {}),
}, {})
};
return { raw, stringified };