forked from atlassian/react-beautiful-dnd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
24 lines (20 loc) · 733 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* eslint-disable id-length */
// @flow
const webpack = require('webpack');
const requireFromString = require('require-from-string');
const MemoryFS = require('memory-fs');
const path = require('path');
const config = require('./webpack.config');
const ports = require('../server-ports');
const fs = new MemoryFS();
const compiler = webpack(config);
// $ExpectError
compiler.outputFileSystem = fs;
// $ExpectError
const outputPath = compiler.compilers.find((cfg) => cfg.name === 'client')
.outputPath;
compiler.run(() => {
const content = fs.readFileSync(path.resolve(outputPath, 'server.js'));
const server = requireFromString(content.toString()).default;
server(process.argv[2] || ports.cspServer, outputPath, fs);
});