diff --git a/.htaccess b/.htaccess new file mode 100644 index 00000000000..77561065da4 --- /dev/null +++ b/.htaccess @@ -0,0 +1,4 @@ + + Header set Cache-Control "public, max-age=31536000, immutable" + Header set Permissions-Policy "browsing-topics=()" + \ No newline at end of file diff --git a/gatsby-config.js b/gatsby-config.js index 7279615b861..ee60d0462bc 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -50,12 +50,6 @@ module.exports = { `https://widget.trustpilot.com/bootstrap/v5/tp.widget.bootstrap.min.js`, ], plugins: [ - // [TODO] Enable this when we have a proper setup to enable caching, Otherwise it will cause one of them stop working. - // resolve: `gatsby-plugin-offline`, - // options: { - // // precachePages: [`/`], - // }, - // }, 'gatsby-plugin-postcss', { resolve: 'gatsby-plugin-html-minifier', diff --git a/package.json b/package.json index 7a599458197..51d762a0e12 100644 --- a/package.json +++ b/package.json @@ -163,7 +163,7 @@ "license": "Apache License 2.0", "scripts": { "analyze-bundle": "GENERATE_JSON_STATS=true gatsby build && npx webpack-bundle-analyzer -m static -r ./webpack-bundle-report/report.html ./public/stats.json", - "build": "GATSBY_CPU_COUNT=2 gatsby build --log-pages", + "build": "GATSBY_CPU_COUNT=2 gatsby build --log-pages && node scripts/copy-htaccess.js", "update:deriv-com-libs": "npm i @deriv-com/blocks@latest @deriv-com/components@latest @deriv-com/hooks@latest @deriv-com/providers@latest", "partytown": "partytown copylib public/~partytown", "develop": "GATSBY_CPU_COUNT=2 gatsby develop -o", diff --git a/scripts/copy-htaccess.js b/scripts/copy-htaccess.js new file mode 100644 index 00000000000..237b5eb2782 --- /dev/null +++ b/scripts/copy-htaccess.js @@ -0,0 +1,16 @@ +const fs = require('fs'); +const path = require('path'); + +// Path to your custom .htaccess file in the project root +const htaccessPath = path.join(__dirname, '..', '.htaccess'); + +// Path to the Gatsby public directory +const publicPath = path.join(__dirname, '..', 'public', '.htaccess'); + +fs.copyFile(htaccessPath, publicPath, (err) => { + if (err) { + console.error('Error copying .htaccess file:', err); + return; + } + console.log('.htaccess file copied successfully.'); +});