From 7ddd5674ca74874ab7e328ba1aeefefa20460dbf Mon Sep 17 00:00:00 2001 From: tsukino <0xtsukino@gmail.com> Date: Tue, 20 Feb 2024 21:46:22 +0800 Subject: [PATCH] refactor: directory structure for server and web --- .prettierignore | 2 +- package.json | 6 +++--- server/index.ts | 2 +- tailwind.config.js | 2 +- tsconfig.json | 4 +++- {src => web}/components/Button/index.scss | 0 {src => web}/components/Button/index.tsx | 0 {src => web}/components/FileUpload/index.tsx | 0 {src => web}/components/Header/index.scss | 0 {src => web}/components/Header/index.tsx | 0 {src => web}/components/Icon/index.scss | 0 {src => web}/components/Icon/index.tsx | 0 {src => web}/components/NotaryKey/index.scss | 0 {src => web}/components/NotaryKey/index.tsx | 0 {src => web}/components/ProofDetails/index.tsx | 0 {src => web}/components/ProofSelect/index.scss | 0 {src => web}/components/ProofSelect/index.tsx | 0 {src => web}/components/types/types.tsx | 0 {src => web}/index.tsx | 0 {src => web}/pages/App/index.scss | 0 {src => web}/pages/App/index.tsx | 0 {src => web}/store/index.ts | 0 {src => web}/store/notaryKey.ts | 0 {src => web}/store/proofupload.ts | 0 {src => web}/utils/index.tsx | 0 {src => web}/utils/keys.json | 0 webpack.server.config.js | 1 - webpack.config.js => webpack.web.config.js | 8 ++++---- 28 files changed, 13 insertions(+), 12 deletions(-) rename {src => web}/components/Button/index.scss (100%) rename {src => web}/components/Button/index.tsx (100%) rename {src => web}/components/FileUpload/index.tsx (100%) rename {src => web}/components/Header/index.scss (100%) rename {src => web}/components/Header/index.tsx (100%) rename {src => web}/components/Icon/index.scss (100%) rename {src => web}/components/Icon/index.tsx (100%) rename {src => web}/components/NotaryKey/index.scss (100%) rename {src => web}/components/NotaryKey/index.tsx (100%) rename {src => web}/components/ProofDetails/index.tsx (100%) rename {src => web}/components/ProofSelect/index.scss (100%) rename {src => web}/components/ProofSelect/index.tsx (100%) rename {src => web}/components/types/types.tsx (100%) rename {src => web}/index.tsx (100%) rename {src => web}/pages/App/index.scss (100%) rename {src => web}/pages/App/index.tsx (100%) rename {src => web}/store/index.ts (100%) rename {src => web}/store/notaryKey.ts (100%) rename {src => web}/store/proofupload.ts (100%) rename {src => web}/utils/index.tsx (100%) rename {src => web}/utils/keys.json (100%) rename webpack.config.js => webpack.web.config.js (95%) diff --git a/.prettierignore b/.prettierignore index 9c9e7ff..fb0aa35 100644 --- a/.prettierignore +++ b/.prettierignore @@ -3,6 +3,6 @@ node_modules wasm tlsn postcss.config.js -webpack.config.js +webpack.web.config.js *.json *.scss \ No newline at end of file diff --git a/package.json b/package.json index a4e5a2b..b632d66 100644 --- a/package.json +++ b/package.json @@ -4,12 +4,12 @@ "description": "", "main": "index.js", "scripts": { - "build:ui": "NODE_ENV=production webpack --config webpack.config.js", + "build:ui": "NODE_ENV=production webpack --config webpack.web.config.js", "build:server": "NODE_ENV=production webpack --config webpack.server.config.js", "watch:server": "webpack --config webpack.server.config.js --watch", - "nodemon:server": "nodemon build/server/index.js", + "nodemon:server": "nodemon build/server/index.bundle.js", "dev:server": "NODE_ENV=development concurrently npm:watch:server npm:nodemon:server", - "dev:ui": "NODE_ENV=development webpack-dev-server --config webpack.config.js --hot" + "dev:ui": "NODE_ENV=development webpack-dev-server --config webpack.web.config.js --hot" }, "repository": { "type": "git", diff --git a/server/index.ts b/server/index.ts index fe44a00..3cf2365 100644 --- a/server/index.ts +++ b/server/index.ts @@ -1,3 +1,3 @@ import express from 'express'; -console.log('hi') \ No newline at end of file +console.log('hi'); \ No newline at end of file diff --git a/tailwind.config.js b/tailwind.config.js index b206fb4..f3c9d7c 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -1,6 +1,6 @@ /** @type {import('tailwindcss').Config} */ module.exports = { - content: ['./src/**/*.{js,jsx,ts,tsx}'], + content: ['./web/**/*.{js,jsx,ts,tsx}'], theme: { extend: { colors: { diff --git a/tsconfig.json b/tsconfig.json index 744f7df..fdf6a20 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,6 +15,8 @@ "noEmit": false, "jsx": "react" }, - "include": ["src"], + "include": [ + "web" + ], "exclude": ["build", "node_modules"] } diff --git a/src/components/Button/index.scss b/web/components/Button/index.scss similarity index 100% rename from src/components/Button/index.scss rename to web/components/Button/index.scss diff --git a/src/components/Button/index.tsx b/web/components/Button/index.tsx similarity index 100% rename from src/components/Button/index.tsx rename to web/components/Button/index.tsx diff --git a/src/components/FileUpload/index.tsx b/web/components/FileUpload/index.tsx similarity index 100% rename from src/components/FileUpload/index.tsx rename to web/components/FileUpload/index.tsx diff --git a/src/components/Header/index.scss b/web/components/Header/index.scss similarity index 100% rename from src/components/Header/index.scss rename to web/components/Header/index.scss diff --git a/src/components/Header/index.tsx b/web/components/Header/index.tsx similarity index 100% rename from src/components/Header/index.tsx rename to web/components/Header/index.tsx diff --git a/src/components/Icon/index.scss b/web/components/Icon/index.scss similarity index 100% rename from src/components/Icon/index.scss rename to web/components/Icon/index.scss diff --git a/src/components/Icon/index.tsx b/web/components/Icon/index.tsx similarity index 100% rename from src/components/Icon/index.tsx rename to web/components/Icon/index.tsx diff --git a/src/components/NotaryKey/index.scss b/web/components/NotaryKey/index.scss similarity index 100% rename from src/components/NotaryKey/index.scss rename to web/components/NotaryKey/index.scss diff --git a/src/components/NotaryKey/index.tsx b/web/components/NotaryKey/index.tsx similarity index 100% rename from src/components/NotaryKey/index.tsx rename to web/components/NotaryKey/index.tsx diff --git a/src/components/ProofDetails/index.tsx b/web/components/ProofDetails/index.tsx similarity index 100% rename from src/components/ProofDetails/index.tsx rename to web/components/ProofDetails/index.tsx diff --git a/src/components/ProofSelect/index.scss b/web/components/ProofSelect/index.scss similarity index 100% rename from src/components/ProofSelect/index.scss rename to web/components/ProofSelect/index.scss diff --git a/src/components/ProofSelect/index.tsx b/web/components/ProofSelect/index.tsx similarity index 100% rename from src/components/ProofSelect/index.tsx rename to web/components/ProofSelect/index.tsx diff --git a/src/components/types/types.tsx b/web/components/types/types.tsx similarity index 100% rename from src/components/types/types.tsx rename to web/components/types/types.tsx diff --git a/src/index.tsx b/web/index.tsx similarity index 100% rename from src/index.tsx rename to web/index.tsx diff --git a/src/pages/App/index.scss b/web/pages/App/index.scss similarity index 100% rename from src/pages/App/index.scss rename to web/pages/App/index.scss diff --git a/src/pages/App/index.tsx b/web/pages/App/index.tsx similarity index 100% rename from src/pages/App/index.tsx rename to web/pages/App/index.tsx diff --git a/src/store/index.ts b/web/store/index.ts similarity index 100% rename from src/store/index.ts rename to web/store/index.ts diff --git a/src/store/notaryKey.ts b/web/store/notaryKey.ts similarity index 100% rename from src/store/notaryKey.ts rename to web/store/notaryKey.ts diff --git a/src/store/proofupload.ts b/web/store/proofupload.ts similarity index 100% rename from src/store/proofupload.ts rename to web/store/proofupload.ts diff --git a/src/utils/index.tsx b/web/utils/index.tsx similarity index 100% rename from src/utils/index.tsx rename to web/utils/index.tsx diff --git a/src/utils/keys.json b/web/utils/keys.json similarity index 100% rename from src/utils/keys.json rename to web/utils/keys.json diff --git a/webpack.server.config.js b/webpack.server.config.js index 141cd75..42d35dc 100755 --- a/webpack.server.config.js +++ b/webpack.server.config.js @@ -37,7 +37,6 @@ var options = { ], }, plugins: [ - isDevelopment && new ReactRefreshWebpackPlugin(), new CleanWebpackPlugin({ verbose: false }), new webpack.ProgressPlugin(), new webpack.EnvironmentPlugin(["NODE_ENV"]), diff --git a/webpack.config.js b/webpack.web.config.js similarity index 95% rename from webpack.config.js rename to webpack.web.config.js index 97694d2..34deadb 100755 --- a/webpack.config.js +++ b/webpack.web.config.js @@ -33,11 +33,11 @@ var options = { /ResizeObserver loop completed with undelivered notifications/ ], entry: { - index: path.join(__dirname, "src", "index.tsx"), + index: path.join(__dirname, "web", "index.tsx"), }, output: { filename: "[name].bundle.js", - path: path.resolve(__dirname, "build"), + path: path.resolve(__dirname, "build", "ui"), clean: true, publicPath: ASSET_PATH, }, @@ -46,7 +46,7 @@ var options = { { // look for .css or .scss files test: /\.(css|scss)$/, - // in the `src` directory + // in the `web` directory use: [ { loader: "style-loader", @@ -132,7 +132,7 @@ var options = { patterns: [ { from: "node_modules/tlsn-js/build", - to: path.join(__dirname, "build"), + to: path.join(__dirname, "build", "ui"), force: true, }, ]