Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into translation-2769-fix-incorrect-image-in-dt…
Browse files Browse the repository at this point in the history
…rader
  • Loading branch information
mitra-deriv committed Jan 26, 2024
2 parents 43f76c5 + 931987e commit ee839bd
Show file tree
Hide file tree
Showing 33 changed files with 10,999 additions and 14,160 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ jobs:
with:
name: production
path: public
retention-days: 5
- name: Slack Notification 📣
uses: 8398a7/action-slack@v3
with:
Expand All @@ -99,6 +100,7 @@ jobs:
build_and_publish_to_docker_k8s:
runs-on: Runner_16cores
environment: production
needs: [release-production]
steps:
- name: Checkout 🛎️
uses: actions/[email protected]
Expand Down
4 changes: 4 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<IfModule mod_headers.c>
Header set Cache-Control "public, max-age=31536000, immutable"
Header set Permissions-Policy "browsing-topics=()"
</IfModule>
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

2 changes: 1 addition & 1 deletion crowdin/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
"71535160": "Calculate the overnight fees for holding any open positions. The fees can be positive or negative depending on your swap rate.",
"71630191": "Do not share your account information and other personal details with anyone via Telegram.",
"71650838": "Speak simply and plainly, and not hide behind ambiguity",
"71755468": "In a journey spanning more than 23 years, we have grown to over 2.5 million customers worldwide. But our mission has remained the same:",
"73765361": "Chief Audit Executive",
"74138086": "Take control of your trades on Deriv MT5",
"74593350": "3. Select Real account or Demo account.",
Expand Down Expand Up @@ -4642,6 +4641,7 @@
"-1520902282": "No credit card needed",
"-2022759357": "Make trading accessible to anyone, anywhere",
"-77779780": "From inception, our goal was to break free of the high commissions and clunky products offered by traditional brokers. Also, we aim to deliver a first-class experience to digitally inclined traders, regardless of the size of their accounts.",
"-1321496264": "In a journey spanning 25 years, we have grown to over 2.5 million customers worldwide. But our mission has remained the same:",
"-554746075": "Integrity",
"-1917169640": "We serve our customers with fairness and transparency. We settle all contracts by the book and speak plainly and truthfully.",
"-1679427554": "Customer focus",
Expand Down
38 changes: 28 additions & 10 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,44 @@ 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',
options: {
collapseWhitespace: true,
decodeEntities: true,
minifyCSS: true,
minifyJS: true,
removeComments: true,
removeEmptyAttributes: true,
removeRedundantAttributes: true,
useShortDoctype: true,
},
},
{
resolve: 'gatsby-plugin-sass',
options: {
postCssPlugins: [
require('postcss-discard-duplicates'),
require('autoprefixer'), // better cross-browser compatibility
plugin({
dest: 'src/classnames.d.ts',
// Set isModule if you want to import ClassNames from another file
// isModule: true,
exportAsDefault: true, // to use in combination with isModule
exportAsDefault: true,
}),
require('cssnano')({
preset: 'default',
preset: [
'default',
{
discardComments: { removeAll: true },
discardUnused: true,
mergeIdents: true,
reduceIdents: true,
mergeRules: true,
minifySelectors: true,
discardEmpty: true,
minifyFontValues: true,
},
],
}),
],
},
Expand Down
120 changes: 69 additions & 51 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ const language_config = require(`./i18n-config.js`)
const language_config_en = require(`./i18n-config-en.js`)
const path = require('path')
const { copyLibFiles } = require('@builder.io/partytown/utils')
const webpack = require('webpack')
const StylelintPlugin = require('stylelint-webpack-plugin')
const TerserPlugin = require('terser-webpack-plugin')

const translations_cache = {}

Expand Down Expand Up @@ -349,48 +352,37 @@ const BuildPage = (page, actions) => {
exports.onCreatePage = ({ page, actions }) => {
const { deletePage } = actions
const isProduction = process.env.GATSBY_ENV === 'production'
const pagesToBuild = process.env.GATSBY_BUILD_PAGES || 'all'

// First delete the incoming page that was automatically created by Gatsby
// So everything in src/pages/
deletePage(page)

const pagesCategory = {
all: [''],
'no-affiliates': ['signup-affiliates', 'landing', 'ctrader', 'partners'],
'no-help-centre': ['help-centre'],
'no-tools': ['trader-tools'],
fast: [
'signup-affiliates',
'landing',
'ctrader',
'partners',
'help-centre',
'trader-tools',
'careers',
// 'markets',
// 'trade-types' Note: Feel free to adjust pages you want to skip building for faster local development
],
}
const pagesToBuild = process.env.GATSBY_BUILD_PAGES
if (pagesToBuild) {
const pages_loaded = pagesToBuild.split(',')
const allowed_pages = ['', pages_loaded]

const disallowedPages = pagesCategory[pagesToBuild] || []
const pages = allowed_pages.reduce((result, Item) => {
if (Array.isArray(Item)) {
// Flatten the nested array and add the '/' prefix
const nested_array = Item.map((subItem) => `/${subItem}/`)
return result.concat(nested_array)
} else {
// Add the '/' prefix for the root item
return result.concat(`/${Item}`)
}
}, [])

const regex = new RegExp(`/${disallowedPages.join('|') + '|'}/g`)
console.log('pages', pages)

const isMatch = regex.test(page.path)

if (isProduction) {
return BuildPage(page, actions)
} else {
if (!isMatch || pagesToBuild === 'all') {
console.log(`\x1b[32mcreating\x1b[0m [${pagesToBuild}] ${page.path}`)
deletePage(page)
if (isProduction) {
return BuildPage(page, actions)
} else {
if (pages.includes(page.path)) {
return BuildPage(page, actions)
}
}
} else {
return BuildPage(page, actions)
}
}

const StylelintPlugin = require('stylelint-webpack-plugin')
const TerserPlugin = require('terser-webpack-plugin')
const style_lint_options = {
files: 'src/**/*.js',
emitErrors: false,
Expand All @@ -399,25 +391,51 @@ const style_lint_options = {

exports.onCreateWebpackConfig = ({ stage, actions, loaders, getConfig }, { ...options }) => {
const config = getConfig()
if (config.optimization) {
config.optimization.minimizer = [new TerserPlugin()]
}
if (stage === 'build-html' || stage === 'develop-html') {
actions.setWebpackConfig({
module: {
rules: [
{
test: /analytics/,
use: loaders.null(),
},
],
},
})
}
const isProduction = config.mode === 'production'

actions.setWebpackConfig({
plugins: [new StylelintPlugin({ ...style_lint_options, ...options })],
devtool: isProduction ? false : 'inline-source-map', // enable/disable source-maps
mode: isProduction ? 'production' : 'development',
optimization: {
minimize: isProduction,
minimizer: [new TerserPlugin()],
// splitChunks: {
// chunks: 'all',
// name: "deriv-com",
// },

mangleExports: 'size',
mangleWasmImports: true,

mergeDuplicateChunks: true,
removeAvailableModules: true,
removeEmptyChunks: true,
innerGraph: true,

chunkIds: 'size',
moduleIds: 'size',

// runtimeChunk: 'single', // compilation fails
sideEffects: true,

concatenateModules: true,
providedExports: true,
usedExports: true,
},
plugins: [
new StylelintPlugin({...style_lint_options, ...options}),
new webpack.optimize.LimitChunkCountPlugin({maxChunks: 1}),
],
resolve: {
modules: [path.resolve(__dirname, 'src'), 'node_modules'],
},
...((stage === 'build-html' || stage === 'develop-html') ? {
module: {
rules: [{
test: /analytics/,
use: loaders.null()
}]
}
} : {}),
})
}
}
Loading

0 comments on commit ee839bd

Please sign in to comment.