Skip to content

Commit

Permalink
build: fix i18n script usage with nx (#3303)
Browse files Browse the repository at this point in the history
  • Loading branch information
anxolin authored Oct 31, 2023
1 parent fb24d41 commit 358d9f2
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 74 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ yarn install
## Generate locale files

```
yarn i18n:extract
yarn i18n
```

## Run the interface
Expand Down
56 changes: 0 additions & 56 deletions apps/cowswap-frontend/lingui.config.ts

This file was deleted.

5 changes: 0 additions & 5 deletions apps/cowswap-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
"ipfs:build": "cross-env PUBLIC_URL=\".\" yarn build",
"ipfs:publish": "npx ipfs-deploy build -p pinata -O",
"patch-package": "npx patch-package",
"i18n": "yarn run i18n:compile",
"i18n:compile": "yarn run i18n:extract && npx lingui compile",
"i18n:extract": "cross-env NODE_ENV=development npx lingui extract --locale en-US",
"i18n:pseudo": "npx lingui extract --locale pseudo && lingui compile",
"postinstall": "yarn run i18n",
"cosmos:clear": "rm -rf ./public/cosmos",
"cosmos:run": "yarn run _cosmos:run",
"build:cosmos": "cross-env NODE_ENV=development npx cosmos-export",
Expand Down
23 changes: 23 additions & 0 deletions apps/cowswap-frontend/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"executor": "@nx/vite:build",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "production",
"dependsOn": ["i18n:compile"],
"options": {
"outputPath": "build/cowswap"
},
Expand Down Expand Up @@ -71,6 +72,28 @@
"options": {
"buildTarget": "cowswap-frontend:build"
}
},

"i18n": {
"executor": "nx:noop",
"dependsOn": ["i18n:compile"]
},
"i18n:compile": {
"executor": "nx:run-commands",
"dependsOn": ["i18n:extract"],
"options": {
"command": "npx lingui compile"
},
"inputs": ["{projectRoot}/src/locales/*.po"],
"outputs": ["{projectRoot}/src/locales/*.js"]
},
"i18n:extract": {
"executor": "nx:run-commands",
"options": {
"command": "cross-env NODE_ENV=development npx lingui extract --locale en-US"
},
"inputs": ["{workspaceRoot}/apps/**/*.{ts,tsx,jsx}", "{workspaceRoot}/libs/**/*.{ts,tsx,jsx}"],
"outputs": ["{projectRoot}/src/locales/*.po"]
}
},
"tags": []
Expand Down
7 changes: 0 additions & 7 deletions apps/cowswap-frontend/src/locales/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion libs/common-utils/src/environments.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('Detect environments using host and path', () => {
})
})

describe('Is production', () => {
describe.only('Is production', () => {
const isProduction = { ...DEFAULT_ENVIRONMENTS_CHECKS, isProd: true }

it('swap.cow.fi', () => {
Expand Down
4 changes: 2 additions & 2 deletions lingui.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const linguiConfig = {
catalogs: [
{
path: '<rootDir>/src/locales/{locale}',
include: ['<rootDir>/src'],
path: '<rootDir>/apps/cowswap-frontend/src/locales/{locale}',
include: ['<rootDir>/apps', '<rootDir>/libs'],
},
],
fallbackLocales: {
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@
"ci:build": "yarn run build:cowswap && yarn run build-widget",
"ipfs:build": "PUBLIC_URL=\".\" yarn build",
"ipfs:publish": "npx ipfs-deploy build -p pinata -O",
"i18n": "nx run-many -t i18n",
"preview": "cross-env NODE_OPTIONS=--max-old-space-size=32768 nx run cowswap-frontend:preview",
"test": "yarn test:all",
"test:all": "nx run-many -t test",
"e2e": "nx run-many -t e2e",
"lint": "nx run-many -t lint",
"prebuild-app": "nx run cowswap-frontend:i18n",
"prebuild-app": "yarn i18n",
"prepare": "husky install",
"postinstall": "yarn run patch-package",
"postinstall": "yarn run patch-package && yarn i18n",
"analyze-build": "cross-env ANALYZE_BUNDLE=true ANALYZE_BUNDLE_TEMPLATE=sunburst yarn build"
},
"browser": {
Expand Down

0 comments on commit 358d9f2

Please sign in to comment.