Skip to content

Commit

Permalink
Extracts handler entry path into constant (DRY)
Browse files Browse the repository at this point in the history
  • Loading branch information
SanjoSolutions committed May 2, 2016
1 parent b30ded7 commit d25c568
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,14 @@ module.exports = function getPlugin(S) {
const webpackConfig = Object.assign({}, config.webpackConfig);
const handlerName = func.getHandler().split('.')[0];
const handlerFileName = `${handlerName}.${config.handlerExt}`;
const handlerEntryPath = `./${handlerFileName}`;

// override entry and output
webpackConfig.context = path.dirname(func.getFilePath());
if (Array.isArray(webpackConfig.entry)) {
webpackConfig.entry.push(`./${handlerFileName}`);
webpackConfig.entry.push(handlerEntryPath);
} else {
webpackConfig.entry = `./${handlerFileName}`;
webpackConfig.entry = handlerEntryPath;
}
webpackConfig.output = {
libraryTarget: 'commonjs',
Expand Down

0 comments on commit d25c568

Please sign in to comment.