Skip to content

Instantly share code, notes, and snippets.

@ndunks
Created June 21, 2019 12:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ndunks/24b8c425c971f335dbd9bcf00fb4fc9b to your computer and use it in GitHub Desktop.
Save ndunks/24b8c425c971f335dbd9bcf00fb4fc9b to your computer and use it in GitHub Desktop.
Get list of excluded module in webpak config
module.exports = function(){
var fs = require("fs");
var nodeExternal = {};
var pkg = JSON.parse(fs.readFileSync('package.json', { encoding: 'utf-8' }));
Object.keys(pkg.dependencies).forEach(function (name) {
nodeExternal[name] = "require('" + name + "')";
});
Object.keys(pkg.devDependencies).filter(function (v) { return !v.match(/@types/); }).forEach(function (name) {
nodeExternal[name] = "require('" + name + "')";
});
console.log('externals', nodeExternal);
return nodeExternal;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment