feat: allow user to modify generated webpack config

This commit is contained in:
endiliey 2018-08-30 03:30:44 +08:00
parent 2b5ee3e869
commit 10b1a38762
9 changed files with 172 additions and 3 deletions

View file

@ -6,6 +6,7 @@ const globby = require('globby');
const load = require('../load');
const createServerConfig = require('../webpack/server');
const createClientConfig = require('../webpack/client');
const {applyConfigureWebpack} = require('../webpack/utils');
function compile(config) {
return new Promise((resolve, reject) => {
@ -36,8 +37,15 @@ module.exports = async function build(siteDir, cliOptions = {}) {
const props = await load(siteDir);
const serverConfig = createServerConfig(props).toConfig();
const clientConfig = createClientConfig(props).toConfig();
let serverConfig = createServerConfig(props).toConfig();
let clientConfig = createClientConfig(props).toConfig();
// apply user webpack config
const {
siteConfig: {configureWebpack}
} = props;
clientConfig = applyConfigureWebpack(configureWebpack, clientConfig, false);
serverConfig = applyConfigureWebpack(configureWebpack, serverConfig, true);
// Build the client bundles first.
// We cannot run them in parallel because the server need to pickup the correct client bundle name