1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | var _path = require('path');
|
8 |
|
9 | var _fs = require('fs');
|
10 |
|
11 | var _rimraf = require('rimraf');
|
12 |
|
13 | var _rimraf2 = _interopRequireDefault(_rimraf);
|
14 |
|
15 | var _safe = require('colors/safe');
|
16 |
|
17 | var _safe2 = _interopRequireDefault(_safe);
|
18 |
|
19 | var _os = require('os');
|
20 |
|
21 | var _child_process = require('child_process');
|
22 |
|
23 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24 |
|
25 | exports.default = function (_ref) {
|
26 | var path = _ref.path,
|
27 | configPath = _ref.configPath,
|
28 | config = _ref.config,
|
29 | verbose = _ref.verbose;
|
30 |
|
31 | var DEFAULT_OUTPUT_PATH = (0, _os.tmpdir)();
|
32 |
|
33 | var webPackPath = require.resolve('webpack/bin/webpack');
|
34 | var rnd = new Date().getTime() + '_' + Math.round(1000000 * Math.random());
|
35 | var outPath = (0, _path.join)(config.output && config.output.path || DEFAULT_OUTPUT_PATH, '.webpack.res.' + rnd + '.js');
|
36 |
|
37 |
|
38 |
|
39 | var webPackStdOut = (0, _child_process.execSync)(['node',
|
40 | webPackPath, path, outPath, '--config', configPath, '--bail'].join(' '));
|
41 |
|
42 | if (verbose) {
|
43 | console.error(
|
44 | _safe2.default.blue('Webpack stdout for ' + path + '\n') +
|
45 | _safe2.default.blue('---------\n') + (webPackStdOut + '\n') + _safe2.default.blue('---------'));
|
46 | }
|
47 |
|
48 | var webPackResult = (0, _fs.readFileSync)(outPath, { encoding: 'utf8' });
|
49 | _rimraf2.default.sync(outPath);
|
50 |
|
51 | return webPackResult;
|
52 | }; |
\ | No newline at end of file |