feat: code split & use react helmet

This commit is contained in:
endiliey 2018-08-23 21:46:14 +08:00
parent bf1e30dc52
commit 406106b67e
19 changed files with 241 additions and 146 deletions

View file

@ -4,7 +4,8 @@ const chalk = require('chalk');
const fs = require('fs-extra');
const globby = require('globby');
const load = require('../load');
const createProdConfig = require('../webpack/prod');
const createServerConfig = require('../webpack/server');
const createClientConfig = require('../webpack/client');
function compile(config) {
return new Promise((resolve, reject) => {
@ -35,11 +36,14 @@ module.exports = async function build(siteDir, cliOptions = {}) {
const props = await load(siteDir);
// create compiler from generated webpack config
const config = createProdConfig(props).toConfig();
const serverConfig = createServerConfig(props).toConfig();
const clientConfig = createClientConfig(props).toConfig();
// compile!
await compile(config);
// we build the client bundles first
await compile(clientConfig);
// then we build the server bundles (render the static HTML and pick client bundle)
await compile(serverConfig);
// copy static files
const {outDir} = props;