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