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-0000-add-ctrader-to-the-availa…
Browse files Browse the repository at this point in the history
…ble-platforms-in-help-centre
  • Loading branch information
mitra-deriv committed Jan 27, 2024
2 parents 6fd1954 + 71b0b02 commit 49328d0
Show file tree
Hide file tree
Showing 56 changed files with 10,922 additions and 14,065 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.

1 change: 0 additions & 1 deletion crowdin/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,6 @@
"1083621931": "Please note that the availability of early exit from your trading position depends on the specific trade type, or it may only be available within a certain timeframe.",
"1084407062": "These indices correspond to simulated markets with <0>constant volatilities of 10%, 25%, 50%, 75%, and 100%.</0> There is an equal probability of an up or down jump <0>every 20 minutes</0>, on average. The jump size is <0>around 30 times</0> the normal price movement, on average.",
"1084960586": "Disclose the terms of all contracts",
"1086118495": "Traders Hub",
"1088428939": "These indices correspond to financial markets with volatilities of 10% and 20%. One tick is generated for every tick of the corresponding forex pair.",
"1089110190": "You accidentally gave us another email address (usually a work or a personal one instead of the one you meant).",
"1089165018": "Get in touch",
Expand Down
2 changes: 1 addition & 1 deletion gatsby-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import { createRoot } from 'react-dom/client'
import Cookies from 'js-cookie'
import { isMobile } from 'react-device-detect'
import { Analytics } from '@deriv/analytics'
import { Analytics } from '@deriv-com/analytics'
import { WrapPagesWithLocaleContext } from './src/components/localization'
import { isProduction } from './src/common/websocket/config'
import { LocalStore } from './src/common/storage'
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 49328d0

Please sign in to comment.