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 parseWPConfig = (config, isProduction) => {
|
16 | let res = wpconfig(isProduction);
|
17 | if (config.setWebpackConfig) {
|
18 | res = config.setWebpackConfig(res);
|
19 | }
|
20 |
|
21 | return res;
|
22 | };
|
23 |
|
24 | exports.build = config => {
|
25 | walkmd(config, () => {
|
26 | const site = path.resolve(process.cwd(), 'site');
|
27 | sh(`rm -rf ${site}`);
|
28 |
|
29 | const compiler = webpack(parseWPConfig(config, true));
|
30 | compiler.run((err, stats) => {
|
31 |
|
32 | });
|
33 | });
|
34 | }
|
35 |
|
36 | exports.dev = config => {
|
37 | walkmd(config, () => {
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 | console.log(11111111);
|
48 | const server = require('./server');
|
49 | const wpConfig = parseWPConfig(config, false);
|
50 | server(config, wpConfig);
|
51 |
|
52 | });
|
53 | } |
\ | No newline at end of file |