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 _shellQuote = require('shell-quote');
|
22 |
|
23 | var _child_process = require('child_process');
|
24 |
|
25 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
26 |
|
27 | exports.default = function (_ref) {
|
28 | var path = _ref.path;
|
29 | var configPath = _ref.configPath;
|
30 | var config = _ref.config;
|
31 | var verbose = _ref.verbose;
|
32 |
|
33 | var DEFAULT_OUTPUT_PATH = (0, _os.tmpdir)();
|
34 |
|
35 | var webPackPath = require.resolve('webpack/bin/webpack');
|
36 | var rnd = new Date().getTime() + '_' + Math.round(1000000 * Math.random());
|
37 | var outPath = (0, _path.join)(config.output.path || DEFAULT_OUTPUT_PATH, '.webpack.res.' + rnd + '.js');
|
38 |
|
39 |
|
40 |
|
41 | var webPackStdOut = (0, _child_process.execSync)((0, _shellQuote.quote)(['node',
|
42 | webPackPath, path, outPath, '--config', configPath, '--colors', '--bail']));
|
43 |
|
44 | if (verbose) {
|
45 | console.log(
|
46 | _safe2.default.blue('Webpack stdout for ' + path + '\n') + _safe2.default.blue('---------\n') + (webPackStdOut + '\n') + _safe2.default.blue('---------'));
|
47 | }
|
48 |
|
49 | var webPackResult = (0, _fs.readFileSync)(outPath, { encoding: 'utf8' });
|
50 | _rimraf2.default.sync(outPath);
|
51 |
|
52 | return webPackResult;
|
53 | }; |
\ | No newline at end of file |