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

@ -10,8 +10,9 @@ const serveStatic = require('koa-static');
const history = require('connect-history-api-fallback');
const portfinder = require('portfinder');
const serve = require('webpack-serve');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const load = require('../load');
const createDevConfig = require('../webpack/dev');
const createClientConfig = require('../webpack/client');
async function getPort(reqPort) {
portfinder.basePort = parseInt(reqPort, 10) || 3000;
@ -52,7 +53,18 @@ module.exports = async function start(siteDir, cliOptions = {}) {
const {baseUrl} = props;
// create compiler from generated webpack config
const config = createDevConfig(props).toConfig();
let config = createClientConfig(props);
const {siteConfig} = props;
config.plugin('html-webpack-plugin').use(HtmlWebpackPlugin, [
{
hash: true,
template: path.resolve(__dirname, '../core/devTemplate.ejs'),
filename: 'index.html',
title: siteConfig.title
}
]);
config = config.toConfig();
const compiler = webpack(config);
// webpack-serve