From 9160cc58759aa13eee77e155dfed6d943646b4c0 Mon Sep 17 00:00:00 2001 From: VaiTon Date: Sun, 9 Jul 2023 15:41:23 +0200 Subject: [PATCH] Use Vite instead of CRA (#663) --- .gitignore | 3 + README.md | 22 +- index.html | 48 + package.json | 13 +- public/index.html | 51 - src/{App.js => App.jsx} | 0 src/components/Footer/DiscoverTheProject.jsx | 1 + src/components/Footer/Donate.jsx | 2 +- .../Footer/DownloadOpenFoodFacts.jsx | 1 + src/components/Footer/OpenFoodFacts.jsx | 2 +- src/components/QuestionFilter/LabelFilter.tsx | 2 +- src/components/welcome/Welcome.jsx | 3 +- src/const.js | 2 +- src/pages/{index.js => index.jsx} | 0 .../{index.js => index.jsx} | 0 vite.config.js | 6 + webpack.config.js | 35 - yarn.lock | 7680 ++--------------- 18 files changed, 646 insertions(+), 7225 deletions(-) create mode 100644 index.html delete mode 100644 public/index.html rename src/{App.js => App.jsx} (100%) rename src/pages/{index.js => index.jsx} (100%) rename src/pages/shouldLoggedinPage/{index.js => index.jsx} (100%) create mode 100644 vite.config.js delete mode 100644 webpack.config.js diff --git a/.gitignore b/.gitignore index 3a1bea685..9e224686d 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,6 @@ yarn-debug.log* yarn-error.log* .idea + +# vite build +dist/ diff --git a/README.md b/README.md index 3ac317b10..d50970aa4 100644 --- a/README.md +++ b/README.md @@ -37,10 +37,10 @@ The main goal is: Every Open Food Facts user can annotate products in a few minu ## Setup: -- Install Node: https://docs.npmjs.com/downloading-and-installing-node-js-and-npm -- Install yarn `npm install --global yarn` -- Install libraries `yarn install` -- run the project locally `yarn start` (available on http://localhost:3000) +- [Install Node](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) +- [Install yarn](https://classic.yarnpkg.com/lang/en/docs/install/) +- Install libraries: `yarn install` +- run the project locally `yarn dev` ## Libraries: @@ -54,19 +54,23 @@ Open Food Facts APIs and [Robotoff](https://github.com/openfoodfacts/robotoff) ## Build -- `yarn build` - -Use a [simple webpack config](https://github.com/facebook/create-react-app/issues/3365#issuecomment-376546407) to bundle in a single file (build/bundle.min.js) and facilitate integration in OFF main site +``` +yarn build +``` ## Countries list -- `yarn countries` +``` +yarn countries +``` Generate the JSON file `src/assets/countries.json` which contains all the countries available on OFF taxonomy. Data are obtained from static.openfoodfacts.org ## Taxonomy auto-complete -- `node update-taxonomy-suggestions.js` +``` +node update-taxonomy-suggestions.js +``` Fetch categories and labels taxonomy from OpenFoodFacts static files, and generate JSON files used by the `Autocomplete` fields. diff --git a/index.html b/index.html new file mode 100644 index 000000000..60119b973 --- /dev/null +++ b/index.html @@ -0,0 +1,48 @@ + + + + + + + + + + + + + Hunger Games + + + + + +
+ + + + + diff --git a/package.json b/package.json index 1313ca31c..0fa184664 100644 --- a/package.json +++ b/package.json @@ -30,23 +30,20 @@ "devDependencies": { "@types/react": "^18.0.27", "@types/react-dom": "^18.0.6", - "babel-loader": "^8.2.5", + "@vitejs/plugin-react": "^4.0.2", "husky": "^8.0.2", "prettier": "2.8.7", "pretty-quick": "^3.1.3", - "react-scripts-ts": "^3.1.0", "typescript": "^4.9.5", - "webpack-cli": "^5.0.1" + "vite": "^4.4.2" }, "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview", "prettier": "prettier --write .", - "start": "react-scripts start", "countries": "node update-countries.js", - "build": "npm run build:react && npm run build:bundle", - "build:react": "react-scripts build", - "build:bundle": "webpack --config webpack.config.js", "test": "react-scripts test", - "eject": "react-scripts eject", "deploy": "bash deploy.sh", "prepare": "husky install" }, diff --git a/public/index.html b/public/index.html deleted file mode 100644 index 3621d370f..000000000 --- a/public/index.html +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - Hunger Games - - - - -
- - - - diff --git a/src/App.js b/src/App.jsx similarity index 100% rename from src/App.js rename to src/App.jsx diff --git a/src/components/Footer/DiscoverTheProject.jsx b/src/components/Footer/DiscoverTheProject.jsx index 397481e8c..e51879902 100644 --- a/src/components/Footer/DiscoverTheProject.jsx +++ b/src/components/Footer/DiscoverTheProject.jsx @@ -60,6 +60,7 @@ const DiscoverTheProject = () => { {discover.map((content) => { return (