Commit 28b1e5d5 authored by 郭志伟's avatar 郭志伟

fix: apollo配置文件引入方式调整

parent 7f02c92a
......@@ -18,6 +18,7 @@ config/plugin.local.js
config/plugin.js
config/config.*.js
config/apollo.json
config/apollo.ssr.json
index.js
config/manifest.json
app/view/*
......
......@@ -9,12 +9,12 @@ export default class EditorController extends Controller {
}
public async home(ctx: Context) {
let cfg = {};
if (process.env.NODE_ENV === 'production') {
const { api, qiniu } = await import(path.resolve('./config/apollo.json'));
cfg = { apollo: {...api, ...qiniu} };
let apollo = {};
if (process.env.NODE_ENV === 'production' && process.env.EGG_SERVER_ENV === 'sit') {
apollo = ctx.app.config.apollo || {};
}
await ctx.renderClient('editor.js', cfg);
await ctx.renderClient('editor.js', { apollo });
}
public async save(ctx: Context) {
......
#!/usr/bin/env node
"use strict";
const path = require('path');
const fs = require('fs');
const apollo = require('@qg/apollo-nodejs');
const npm = require("npm");
npm.load(() => {
apollo.load({
appId: 'quantum-block-h5',
configPath: path.resolve(__dirname, '../config'),
}).then(() => {
const { api, qiniu } = require(path.resolve('./config/apollo.json'));
fs.writeFileSync(path.resolve('./config/apollo.ssr.json'), JSON.stringify({ ...api, ...qiniu }));
});
});
\ No newline at end of file
#!/usr/bin/env node
"use strict";
const path = require('path');
const fs = require('fs');
const apollo = require('@qg/apollo-nodejs');
"use strict";
const npm = require("npm");
npm.load(() => {
apollo.load({
appId: 'quantum-blocks',
appId: 'quantum-block-h5',
configPath: path.resolve(__dirname, '../config'),
}).then(() => {
console.log(">>> apollo file", require(path.resolve('./config/apollo.json')));
const { api, qiniu } = require(path.resolve('./config/apollo.json'));
fs.writeFileSync(path.resolve('./config/apollo.ssr.json'), JSON.stringify({ ...api, ...qiniu }));
if (process.env.NODE_ENV === 'production') {
npm.run("start");
} else {
npm.run("test");
}
});
});
\ No newline at end of file
});
\ No newline at end of file
......@@ -2,8 +2,8 @@
const path = require('path');
import { Application, EggAppConfig } from 'egg';
const { mysql, redis, api, qiniu } = require(path.resolve('./config/apollo.json'));
export default (appInfo: EggAppConfig) => {
const { mysql, redis } = require(path.resolve('./config/apollo.json'));
const exports: any = {};
exports.logger = {
dir: '/home/quant_group/logs',
......@@ -20,5 +20,5 @@ export default (appInfo: EggAppConfig) => {
},
client: redis
};
return exports;
return {...exports, apollo: { ...api, ...qiniu }};
};
......@@ -9,6 +9,7 @@
"backend": "nohup egg-scripts start --port 7001 --workers 4",
"dev": "egg-bin dev -r egg-ts-helper/register",
"debug": "egg-bin debug -r egg-ts-helper/register",
"apollo": "node bin/apollo.js",
"build": "easy build --devtool",
"tsc": "ets && tsc -p tsconfig.json",
"clean": "ets clean",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment