aws-iot-device-sdkbufferprocessutil@types/aws-iot-device-sdk(optional)
While using @nrwl/web:build as the executor for the build target, add a custom webpack config file to your build configurations:
// apps/<your-app-name>/project.json
{
"targets": {
"build": {
"configurations": {
"local": {
"webpackConfig": "apps/<your-app-name>/webpack.config.js"
}
// Same for "sandbox", "production" and any other configurations
}
},
"serve": {
"configurations": {
"local": {
"buildTarget": "<your-app-name>:build:local"
},
// Same for "sandbox", "production" and any other configurations
}
}
}
}Add the following to your webpack config:
// apps/<your-app-name>/webpack.config.js
const generateConfig = require('@nrwl/react/plugins/webpack');
const webpack = require('webpack');
module.exports = (config) => {
const newConfig = generateConfig(config);
newConfig.node = {
...newConfig.node,
global: true,
};
newConfig.plugins = [
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
}),
new webpack.ProvidePlugin({
process: 'process/browser',
}),
...newConfig.plugins,
];
newConfig.resolve = {
...newConfig.resolve,
fallback: {
...newConfig.resolve.fallback,
fs: false,
path: false,
tls: false,
crypto: false,
buffer: require.resolve('buffer/'),
},
};
return newConfig;
};Now you should be able to just import iot from 'aws-iot-device-sdk'; inside your application and any libs.