Skip to content

Commit

Permalink
chore: alter project build tools to use NX and Vite for front-end. (#65)
Browse files Browse the repository at this point in the history
* chore: add nx to repository

* ci: alter job to use nx script

* chore: migrate from CRA to Vite

* chore: fix docker image to use dist folder instead of build
  • Loading branch information
jpedroh authored Sep 6, 2022
1 parent 392f248 commit 52a162b
Show file tree
Hide file tree
Showing 15 changed files with 1,282 additions and 22,196 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
name: CI
on: push
on:
- push
- pull_request
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn --frozen-lockfile
- name: Build application packages
run: |
yarn workspace @mach/common run build
yarn workspace @mach/database run build
yarn workspace @mach/rpl-crawler run build
- run: yarn nx run-many --target=build
- run: yarn test
build_rest_api:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
yarn workspace @mach/front build
env:
SKIP_PREFLIGHT_CHECK: true
REACT_APP_APP_VERSION: ${{ github.event.release.tag_name }}
VITE_APP_VERSION: ${{ github.event.release.tag_name }}
- name: Deploy
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
Expand Down
25 changes: 25 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"extends": "nx/presets/npm.json",
"tasksRunnerOptions": {
"default": {
"runner": "nx/tasks-runners/default",
"options": {
"cacheableOperations": [
"build",
"test",
"eject"
]
}
}
},
"targetDefaults": {
"build": {
"dependsOn": [
"^build"
]
}
},
"affected": {
"defaultBase": "master"
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"jest": "^26.2.2",
"semantic-release": "^17.4.3",
"ts-jest": "^26.1.4",
"typescript": "^4.2.4"
"typescript": "^4.2.4",
"nx": "14.6.4"
},
"scripts": {
"test": "yarn jest",
Expand Down
4 changes: 2 additions & 2 deletions packages/front/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM node:lts AS build

ARG APP_VERSION_ARG=v0.0.0
ENV REACT_APP_APP_VERSION=$APP_VERSION_ARG
ENV VITE_APP_VERSION=$APP_VERSION_ARG
ENV SKIP_PREFLIGHT_CHECK=true
ENV PUBLIC_URL=/

Expand All @@ -23,5 +23,5 @@ RUN yarn workspace @mach/common build
RUN yarn workspace @mach/front build

FROM nginx:1.15-alpine
COPY --from=build /usr/src/app/packages/front/build /usr/share/nginx/html
COPY --from=build /usr/src/app/packages/front/dist /usr/share/nginx/html
COPY packages/front/nginx/nginx.conf /etc/nginx/conf.d/default.conf
43 changes: 22 additions & 21 deletions packages/front/public/index.html → packages/front/index.html
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="An open source tool for flight simulation"
/>
<!--

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="An open source tool for flight simulation" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
<link rel="manifest" href="/manifest.json" />
<!--
Notice the use of in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
Unlike "/favicon.ico" or "favicon.ico", "/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Mach</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
<title>Mach</title>
</head>

<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
Expand All @@ -37,5 +36,7 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
<script type="module" src="src/index.tsx"></script>
</body>

</html>
Loading

0 comments on commit 52a162b

Please sign in to comment.