mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-12-24 22:19:48 +05:30
Move to .env configuration
This commit is contained in:
parent
3b971aca06
commit
39c186e341
10
.env.tpl
Normal file
10
.env.tpl
Normal file
@ -0,0 +1,10 @@
|
||||
SENTRY_CDN=https://<key>@sentry.io/<project>
|
||||
|
||||
CROWDIN_API_KEY=abc
|
||||
|
||||
GA_ID=UA-XXXXX-Y
|
||||
|
||||
API_HOST=https://dev.account.ely.by
|
||||
|
||||
VERSION=dev
|
||||
ENVIRONMENT=dev
|
14
config.js
Normal file
14
config.js
Normal file
@ -0,0 +1,14 @@
|
||||
/* eslint-env node */
|
||||
|
||||
require('dotenv').config();
|
||||
|
||||
const { env } = process;
|
||||
|
||||
module.exports = {
|
||||
version: env.VERSION || env.NODE_ENV,
|
||||
environment: env.ENVIRONMENT || env.NODE_ENV,
|
||||
apiHost: env.API_HOST || 'https://dev.account.ely.by',
|
||||
ga: env.GA_ID && { id: env.GA_ID },
|
||||
sentryCdn: env.SENTRY_CDN,
|
||||
crowdinApiKey: env.CROWDIN_API_KEY
|
||||
};
|
@ -99,6 +99,7 @@
|
||||
"csp-webpack-plugin": "^2.0.2",
|
||||
"css-loader": "^3.0.0",
|
||||
"cssnano": "^4.1.10",
|
||||
"dotenv": "^8.2.0",
|
||||
"eager-imports-webpack-plugin": "^1.0.0",
|
||||
"enzyme": "^3.8.0",
|
||||
"enzyme-adapter-react-16": "^1.7.1",
|
||||
|
@ -4,22 +4,21 @@
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import CrowdinApi from 'crowdin-api';
|
||||
import MultiProgress from 'multi-progress';
|
||||
import ch from 'chalk';
|
||||
import iso639 from 'iso-639-1';
|
||||
import prompt from 'prompt';
|
||||
|
||||
const CONFIG_PATH = path.resolve(`${__dirname}/../config/env.js`);
|
||||
if (!fs.existsSync(CONFIG_PATH)) {
|
||||
console.error('To use this scripts please create config/env.js file first');
|
||||
import config from '../config';
|
||||
|
||||
if (!config.crowdinApiKey) {
|
||||
console.error(ch.red`crowdinApiKey is required`);
|
||||
process.exit(126);
|
||||
}
|
||||
|
||||
const PROJECT_ID = 'elyby';
|
||||
// $FlowFixMe this will be missing on CI server
|
||||
const PROJECT_KEY = require('./../config/env.js').crowdinApiKey;
|
||||
const PROJECT_KEY = config.crowdinApiKey;
|
||||
const CROWDIN_FILE_PATH = 'accounts/site.json';
|
||||
const SOURCE_LANG = 'en';
|
||||
const LANG_DIR = path.resolve(`${__dirname}/../src/i18n`);
|
||||
|
@ -4,7 +4,6 @@ require('@babel/register');
|
||||
|
||||
const path = require('path');
|
||||
const webpack = require('webpack');
|
||||
const chalk = require('chalk');
|
||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const SitemapPlugin = require('sitemap-webpack-plugin').default;
|
||||
@ -13,24 +12,13 @@ const WebpackBar = require('webpackbar');
|
||||
const SpeedMeasurePlugin = require('speed-measure-webpack-plugin');
|
||||
const EagerImportsPlugin = require('eager-imports-webpack-plugin').default;
|
||||
const {BundleAnalyzerPlugin} = require('webpack-bundle-analyzer');
|
||||
const config = require('./config');
|
||||
|
||||
const SUPPORTED_LANGUAGES = Object.keys(require('./src/i18n/index.json'));
|
||||
const localeFlags = require('./src/components/i18n/localeFlags').default;
|
||||
const rootPath = path.resolve('./src');
|
||||
const outputPath = path.join(__dirname, 'dist');
|
||||
|
||||
let config = {};
|
||||
try {
|
||||
config = require('./config/env.js');
|
||||
} catch (err) {
|
||||
console.log(
|
||||
chalk.yellow('\nCan not find config/env.js. Running with defaults\n\n')
|
||||
);
|
||||
|
||||
if (err.code !== 'MODULE_NOT_FOUND') {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
const isProduction = process.argv.some((arg) => arg === '-p');
|
||||
const isAnalyze = process.argv.some((arg) => arg === '--analyze');
|
||||
|
@ -3437,6 +3437,11 @@ dot-prop@^4.1.1:
|
||||
dependencies:
|
||||
is-obj "^1.0.0"
|
||||
|
||||
dotenv@^8.2.0:
|
||||
version "8.2.0"
|
||||
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.2.0.tgz#97e619259ada750eea3e4ea3e26bceea5424b16a"
|
||||
integrity sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==
|
||||
|
||||
duplexer@^0.1.1:
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1"
|
||||
|
Loading…
Reference in New Issue
Block a user