build.js
1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
process.env.NODE_ENV = 'production';
const rm = require('rimraf');
const path = require('path');
const webpack = require('webpack');
const clientConfig = require('./webpack.client.conf');
const serverConfig = require('./webpack.server.conf');
const pkg = require('../package.json');
const distDir = path.join(__dirname, `../public/dist/${pkg.name}`);
rm(path.join(clientConfig.output.path), err => {
if (err) {
throw err;
}
webpack(clientConfig, (clientErr, clientStats) => {
if (clientErr) {
throw clientErr;
}
process.stdout.write(clientStats.toString({
colors: true,
modules: false,
children: false,
chunks: false,
chunkModules: false
}) + '\n\n');
rm(path.join(distDir, './static'), rmerr => {
if (err) {
throw rmerr;
}
webpack(serverConfig, (serverErr, serverStats) => {
if (serverErr) {
throw serverErr;
}
process.stdout.write(serverStats.toString({
colors: true,
modules: false,
children: false,
chunks: false,
chunkModules: false
}) + '\n\n');
});
});
});
});