-
Notifications
You must be signed in to change notification settings - Fork 294
Using with Webpack
Dmitry Chestnykh edited this page Aug 9, 2014
·
9 revisions
If you use TweetNaCl.js with Webpack, it will include a lot of useless Node shims, because TweetNaCl.js tries to be compatible with browser and Node.js.
To avoid this, tell Webpack to not parse TweetNaCl.js and tweak exported/imported variables wit exports-loader
and imports-loader
in config (here we also do this for TweetNaCl-auth plugin):
module.exports = {
...
module: {
loaders: [
{
test: /\/tweetnacl\//,
loader: 'exports?window.nacl!imports?this=>window,module=>{},require=>false'
},
{
test: /\/tweetnacl-auth\//,
loader: 'exports?window.nacl.auth!imports?this=>window,module=>{},require=>false'
}
],
noParse: [
/\/tweetnacl\//,
/\/tweetnacl-auth\//
]
}
(Make sure to have imports-loader
and exports-loader
packages installed.)