1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | const wpconfig = require('../webpack.config');
|
7 | const webpack = require('webpack');
|
8 | const walkmd = require('./walkmd');
|
9 | const sh = require('child_process').execSync;
|
10 | const path = require('path');
|
11 |
|
12 | const node_modules = path.resolve(__dirname, '../node_modules');
|
13 | const wpconfigPath = path.resolve(__dirname, '../webpack.config.js');
|
14 |
|
15 | const server = require('./server');
|
16 |
|
17 | const parseWPConfig = (config, isProduction) => {
|
18 | let res = wpconfig(isProduction);
|
19 | if (config.setWebpackConfig) {
|
20 | res = config.setWebpackConfig(res);
|
21 | }
|
22 |
|
23 | return res;
|
24 | };
|
25 |
|
26 | exports.build = config => {
|
27 | walkmd(config, () => {
|
28 | const site = path.resolve(process.cwd(), 'site');
|
29 | sh(`rm -rf ${site}`);
|
30 |
|
31 | const compiler = webpack(parseWPConfig(config, true));
|
32 | compiler.run((err, stats) => {
|
33 |
|
34 | });
|
35 | });
|
36 | }
|
37 |
|
38 | exports.dev = config => {
|
39 | walkmd(config, () => {
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 | const wpConfig = parseWPConfig(config, false);
|
50 | server(config, wpConfig);
|
51 |
|
52 | });
|
53 | } |
\ | No newline at end of file |