Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vite #2289

Merged
merged 17 commits into from
Nov 20, 2024
Merged

Vite #2289

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
*.md
!README.md
**/node_modules
**/db/demo-db
**/db/demo-db
7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
FROM node:lts-bullseye-slim as clientBuilder

ENV NODE_ENV "production"
ENV NODE_OPTIONS=--openssl-legacy-provider

RUN mkdir /app
WORKDIR /app
COPY client/package.json .
COPY client/package-lock.json .
RUN npm ci --legacy-peer-deps
RUN npm ci
COPY client .

ENV NODE_ENV "production"
RUN npm run build
RUN echo package.json

Expand Down Expand Up @@ -44,7 +43,7 @@ RUN npm ci --quiet

COPY --from=serverBuilder /usr/src/app/build ./
COPY ./server/uploads ./uploads
COPY --from=clientBuilder /app/build ./client/build
COPY --from=clientBuilder app/dist ./client/build

# we don't want to run as sudo so create group and user
RUN groupadd -r fola && useradd --no-log-init -r -g fola fola
Expand Down
4 changes: 2 additions & 2 deletions client/.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
REACT_APP_TENANT_ID=1
REACT_APP_MAPBOX_ACCESS_TOKEN=pk.eyJ1IjoibHVjYXNob21lciIsImEiOiJjazFqcnRjcm0wNmZ1M2JwZXg2eDFzMXd3In0.yYpkKLrFCxF-qyBfZH1a8w
VITE_TENANT_ID=1
VITE_MAPBOX_ACCESS_TOKEN=pk.eyJ1IjoibHVjYXNob21lciIsImEiOiJjazFqcnRjcm0wNmZ1M2JwZXg2eDFzMXd3In0.yYpkKLrFCxF-qyBfZH1a8w
SKIP_PREFLIGHT_CHECK=true
1 change: 1 addition & 0 deletions client/__mocks__/fileMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = "test-file-stub";
1 change: 1 addition & 0 deletions client/__mocks__/styleMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {};
13 changes: 13 additions & 0 deletions client/babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"presets": [
["@babel/preset-env", { "targets": { "node": "current" } }],
["@babel/preset-react", { "runtime": "automatic" }],
[
"babel-preset-vite",
{
"env": true,
"glob": false
}
]
]
}
7 changes: 0 additions & 7 deletions client/craco.config.js

This file was deleted.

18 changes: 5 additions & 13 deletions client/public/index.html → client/index.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<!DOCTYPE html>
<html lang="en" height="100%">
<head>
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<link rel="shortcut icon" href="/favicon.ico" />
<meta name="viewport" content="minimum-scale=1, initial-scale=1" />
<!-- <meta
name="viewport"
content="minimum-scale=1, initial-scale=1, width=device-width, shrink-to-fit=no"
/> -->
<meta name="theme-color" content="#000000" />
<meta property="og:image" content="%PUBLIC_URL%/FoodOasisLogo.png" />
<meta property="og:image" content="/FoodOasisLogo.png" />
<meta property="og:image:type" content="image/png" />
<meta property="og:image:width" content="639" />
<meta property="og:image:height" content="162" />
Expand All @@ -17,7 +17,7 @@
content="Food Oasis is a non-profit, volunteer-run directory of free food resources in the Los Angeles area."
/>
<meta property="og:locale" content="en_US" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/favicon.ico" />
<link rel="apple-touch-icon" href="/favicon.ico" />
<link
href="https://api.tiles.mapbox.com/mapbox-gl-js/v1.4.0/mapbox-gl.css"
rel="stylesheet"
Expand All @@ -27,16 +27,7 @@
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.
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
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`.
-->
<link rel="manifest" href="/manifest.json" />
<style>
html,
#body,
Expand Down Expand Up @@ -107,5 +98,6 @@
<div class="spinner"></div>
</div>
</div>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
26 changes: 26 additions & 0 deletions client/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const { pathsToModuleNameMapper } = require("ts-jest");
const { compilerOptions } = require("./tsconfig");

/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
roots: ["<rootDir>"],
preset: "ts-jest",
testEnvironment: "./jest.environment.cjs",
modulePaths: [compilerOptions.baseUrl],
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths ?? {}),
transform: {
".+\\.(css|less|sass|scss|png|jpg|gif|ttf|woff|woff2|svg)$":
"jest-transform-stub",
"^.+\\.[t|j]sx?$": "babel-jest",
},
transformIgnorePatterns: [
'node_modules/(?!' +
[
'debounce-fn',
'mimic-fn',,
].join('|') +
')',
],
moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
setupFilesAfterEnv: ["<rootDir>/setupTests.ts"]
};
12 changes: 12 additions & 0 deletions client/jest.environment.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const Environment = require("jest-environment-jsdom").default;

module.exports = class CustomTestEnvironment extends Environment {
async setup() {
await super.setup();
this.global.TextEncoder = TextEncoder;
this.global.TextDecoder = TextDecoder;
this.global.Response = Response;
this.global.Request = Request;

}
};
Loading
Loading