Browse Source

Fix Docker build (#923)

* fixes

* Remove deasync from tests #916

Co-authored-by: corpglory-dev <dev@corpglory.com>
pull/1/head
rozetko 4 years ago committed by GitHub
parent
commit
e12a9b2fa5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 33
      server/build/webpack.prod.conf.js
  2. 2
      server/package.json
  3. 2
      server/spec/setup_tests.ts

33
server/build/webpack.prod.conf.js

@ -7,32 +7,11 @@ const fs = require('fs');
var base = require('./webpack.base.conf');
const TARGET_NODE_VERSION = process.versions.node;
const PLATFORM = `${process.platform}-${process.arch}-node-${TARGET_NODE_VERSION.split('.')[0]}`;
const DEASYNC_NODE_MODULES_PATH = path.resolve('node_modules', 'deasync', 'bin', PLATFORM);
const DEASYNC_DIST_PATH = path.resolve('dist', 'bin', PLATFORM);
console.log(`Target node version: ${TARGET_NODE_VERSION}`);
console.log(`Platform: ${PLATFORM}`);
if(!fs.existsSync(DEASYNC_NODE_MODULES_PATH)) {
throw new Error(`deasync doesn't support this platform: ${PLATFORM}`);
}
base.mode = 'production';
base.output.filename = "server.js";
base.optimization.minimize = true;
base.externals = base.externals ? base.externals : [];
base.externals.push(
function (context, request, callback) {
if(request.indexOf('bindings') === 0) {
callback(null, `() => require('./deasync.node')`)
} else {
callback();
}
}
);
const prodRules = [
{
test: /\.js$/,
@ -57,18 +36,6 @@ const prodRules = [
}
];
let contextPathMapping = {};
contextPathMapping[path.resolve(DEASYNC_DIST_PATH, 'deasync')] = './deasync.node';
const prodPlugins = [
new webpack.ContextReplacementPlugin(
/deasync/,
DEASYNC_NODE_MODULES_PATH,
contextPathMapping
)
];
base.module.rules = [...base.module.rules, ...prodRules];
base.plugins = [...base.plugins, ...prodPlugins];
module.exports = base;

2
server/package.json

@ -53,7 +53,7 @@
"nodemon": "^1.17.5",
"ts-jest": "^23.1.1",
"ts-loader": "^4.4.1",
"typescript": "^2.8.3",
"typescript": "^3.9.5",
"url": "^0.11.0",
"webpack": "^4.12.0",
"webpack-cli": "^3.0.8",

2
server/spec/setup_tests.ts

@ -13,7 +13,5 @@ jest.mock('../src/config.ts', () => ({
AlertTypes: jest.requireActual('../src/config').AlertTypes,
}));
jest.mock('deasync', () => ({ loopWhile: jest.fn() }));
clearSegmentsDB();
createTestDB();

Loading…
Cancel
Save