fix(v2): check static dir exist before copying (#1526)

This commit is contained in:
Endi 2019-05-29 15:43:45 +07:00 committed by Yangshun Tay
parent 517dbc500d
commit 831d96e8e8

View file

@ -68,16 +68,21 @@ export async function build(
].filter(Boolean) as Plugin[],
});
let serverConfig: Configuration = merge(createServerConfig(props), {
plugins: [
new CopyWebpackPlugin([
{
from: path.resolve(siteDir, STATIC_DIR_NAME),
to: outDir,
},
]),
],
});
let serverConfig: Configuration = createServerConfig(props);
const staticDir = path.resolve(siteDir, STATIC_DIR_NAME);
if (fs.existsSync(staticDir)) {
serverConfig = merge(serverConfig, {
plugins: [
new CopyWebpackPlugin([
{
from: staticDir,
to: outDir,
},
]),
],
});
}
// Plugin lifecycle - configureWebpack
plugins.forEach(plugin => {