Created
December 29, 2015 17:36
-
-
Save cdaringe/d5111497e54eff9be9c2 to your computer and use it in GitHub Desktop.
webpack-external-regex-use-node-require.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var getExternals = function() { | |
var internals = [/react/]; // assert that all of these entries remain in webpack bundle | |
var externals = []; | |
var externalsHash = { | |
fs: 'commonjs fs', | |
ipc: 'commonjs ipc', | |
remote: 'commonjs remote', | |
path: 'commonjs path', | |
config: 'commonjs config', | |
os: 'commonjs os', | |
}; | |
// add all packages to externals that aren't otherwise explicity internal | |
Object.keys(require('./package.json').dependencies).forEach(function(packageName) { | |
var isInternal = internals.some(function(internal) { return packageName.match(internal) }); | |
if (isInternal) { | |
return; | |
} | |
externalsHash[packageName] = 'commonjs ' + packageName | |
}); | |
externals.push(externalsHash); | |
externals.push(/app\/common\/.*js/); // don't pack anything with /app/common/ in the path (risky, but probably ok) | |
externals.push(/common\/boot\.js/); | |
externals.push(/app\/main\/.*js/); | |
return externals; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment