Files
TouchPassr/webpack.config.js
2017-12-28 22:51:10 -08:00

54 lines
1.2 KiB
JavaScript

const glob = require("glob");
const path = require("path");
const package = require("./package.json");
const getEntriesAndSources = () => {
return package.shenanigans.entries === undefined
? [
{
entry: `./src/${package.shenanigans.name}.js`,
name: package.shenanigans.name,
sources: [
"./**/*.js",
"!./**/*.test.js",
]
}
]
: package.shenanigans.entries;
};
const getExternals = (shenanigans) => {
const output = {};
if (shenanigans.externals === undefined) {
return output;
}
for (const external of shenanigans.externals) {
output[external.name] = external.name;
}
return output;
};
const externals = getExternals(package.shenanigans);
const entriesAndSources = getEntriesAndSources();
const entry = {};
for (const pair of entriesAndSources) {
entry[pair.name] = pair.entry;
}
// multiple entries?
module.exports = {
entry, // IDictionary<string>
externals,
output: {
filename: "[name].js",
libraryTarget: "amd",
path: path.join(__dirname, "dist"),
}
};