Skip to content

Instantly share code, notes, and snippets.

@AndrewBuntsev
Created December 20, 2020 01:58
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 AndrewBuntsev/8658936264dce3c65775fea35543847d to your computer and use it in GitHub Desktop.
Save AndrewBuntsev/8658936264dce3c65775fea35543847d to your computer and use it in GitHub Desktop.
const fs = require("fs");
const AWS = require("aws-sdk");
const cognitoIdentityServiceProvider = new AWS.CognitoIdentityServiceProvider({ region: 'us-east-1' });
const styles = fs
.readFileSync("styling.css", "utf8")
.replace(/(\r\n\t|\n|\r\t)/gm, "") //remove newlines
.replace("/*.+?*/"); // remove comments
const image = fs.readFileSync('logo.png');
const params = {
UserPoolId: '<your-user-pool-id>',
CSS: styles,
ImageFile: Buffer.from(image)
};
cognitoIdentityServiceProvider.setUICustomization(params, (err, data) => {
if (err) console.log(err, err.stack); // error
else console.log(`Successfully updated, new css version: ${data.UICustomization.CSSVersion}`); // successful response
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment