Skip to content

Commit

Permalink
Merge pull request #21 from kchung/warn-same-source
Browse files Browse the repository at this point in the history
Warn same source
  • Loading branch information
biilmann authored Apr 2, 2018
2 parents f504b42 + 711b1da commit 60bbe7a
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ function webpackConfig(dir, additionalConfig) {
];
}

var functionsDir = config.build.functions || config.build.Functions;
var functionsPath = path.join(process.cwd(), functionsDir);
var dirPath = path.join(process.cwd(), dir);

if (dirPath === functionsPath) {
throw new Error("Function source and publish folder should be in different locations");
}

var webpackConfig = {
module: {
rules: [
Expand All @@ -35,21 +43,18 @@ function webpackConfig(dir, additionalConfig) {
}
]
},
context: path.join(process.cwd(), dir),
context: dirPath,
entry: {},
target: "node",
plugins: [new webpack.IgnorePlugin(/vertx/)],
output: {
path: path.join(
process.cwd(),
config.build.functions || config.build.Functions
),
path: functionsPath,
filename: "[name].js",
libraryTarget: "commonjs"
},
devtool: false
};
fs.readdirSync(path.join(process.cwd(), dir)).forEach(function(file) {
fs.readdirSync(dirPath).forEach(function(file) {
if (file.match(/\.js$/)) {
var name = file.replace(/\.js$/, "");
webpackConfig.entry[name] = "./" + name;
Expand Down

0 comments on commit 60bbe7a

Please sign in to comment.