Skip to content

Commit

Permalink
chore: remove trustpilot fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
prince-deriv committed Jun 26, 2024
1 parent 4a68556 commit 2aa64e7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 39 deletions.
2 changes: 1 addition & 1 deletion crowdin/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -4304,7 +4304,7 @@
"-204765990": "Terms of use",
"-26610045": "Add an affiliate account",
"-435672026": "Wrong email",
"-37998160": "Please enter 3-20 Latin characters, numbers.",
"-1631852396": "Please enter 3-30 Latin characters, numbers.",
"-1458676679": "You should enter 2-50 characters.",
"-442533603": "Incorrect company name",
"-859572487": "You should enter 2-20 characters.",
Expand Down
59 changes: 21 additions & 38 deletions themes/gatsby-theme-deriv/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const path = require('path')
const { exec } = require('child_process')
const StylelintPlugin = require('stylelint-webpack-plugin')
const TerserPlugin = require('terser-webpack-plugin')
const minify = require('html-minifier').minify;
const fs = require('fs');
const minify = require('html-minifier').minify
const fs = require('fs')

const translations_cache = {}

Expand All @@ -23,20 +23,6 @@ function OSFunction() {
}
}

const fetchTrustpilotData = () => {
// Trustpilot on-build data fetching
const os = new OSFunction()

os.execCommand('node scripts/trustpilot.js', (returnvalue) => {
console.log(returnvalue)
})
}

exports.onPreInit = () => {
// Update truspilot.json file with latest data
fetchTrustpilotData()
}

// Based upon https://github.com/gatsbyjs/gatsby/tree/master/examples/using-i18n

const BuildPage = (page, actions, region) => {
Expand Down Expand Up @@ -377,7 +363,7 @@ const BuildPage = (page, actions, region) => {
}
exports.onCreatePage = ({ page, actions }, options) => {
const { deletePage } = actions
const {region} = options;
const { region } = options
const isProduction = process.env.GATSBY_ENV === 'production'
const pagesToBuild = process.env.GATSBY_BUILD_PAGES
if (pagesToBuild) {
Expand Down Expand Up @@ -494,32 +480,29 @@ const minificationOptions = {
useShortDoctype: true,
}

exports.onPostBuild = (_, {buildDirPath}) => {
exports.onPostBuild = (_, { buildDirPath }) => {
return new Promise((resolve, reject) => {
// do async work
console.log('=== HMTL minification started ===');
console.log('=== HMTL minification started ===')

console.log('full path', buildDirPath);
console.log('full path', buildDirPath)
fs.readFile(buildDirPath, 'utf8', (err, inp) => {
if (err) {
reject();
throw err;
reject()
throw err
}
var result = minify(inp, minificationOptions);
var reducedPercentage = (
((inp.length - result.length) / inp.length) *
100
).toFixed(2);
console.log(`We have reduced index.html by ${reducedPercentage}%`);

fs.writeFile(buildDirPath, result, err2 => {
var result = minify(inp, minificationOptions)
var reducedPercentage = (((inp.length - result.length) / inp.length) * 100).toFixed(2)
console.log(`We have reduced index.html by ${reducedPercentage}%`)

fs.writeFile(buildDirPath, result, (err2) => {
if (err2) {
reject();
throw err;
reject()
throw err
}
console.log('index.html has been saved!');
resolve();
});
});
});
};
console.log('index.html has been saved!')
resolve()
})
})
})
}

0 comments on commit 2aa64e7

Please sign in to comment.