Skip to content
This repository has been archived by the owner on Nov 28, 2024. It is now read-only.

fix study_aboard_planning #29

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion electron-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
"main": ".webpack/main",
"scripts": {
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make",
"upload": "scp -r -i ~/.ssh/liuwei_rsa \"out/make/squirrel.windows/x64/PrivataClient-1.0.0 Setup.exe\" [email protected]:/home/ubuntu/FM-APIs/statics/PrivataClient-1.0.0.Setup.exe",
"package": "electron-forge package",
"publish": "electron-forge publish",
"lint": "eslint --ext .ts,.tsx ."
},
Expand Down
8,013 changes: 0 additions & 8,013 deletions electron-app/pnpm-lock.yaml

This file was deleted.

1 change: 1 addition & 0 deletions react-app/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
PORT=3001
DATABASE_URL=file:./dev.db
REACT_APP_API_ENDPOINT=http://localhost:8000
1 change: 1 addition & 0 deletions react-app/.env.production
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
GENERATE_SOURCEMAP=false
REACT_APP_API_ENDPOINT=http://aidvisor.valmech.net
98 changes: 66 additions & 32 deletions react-app/craco.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
// We have .ts file in node_modules/, but react won't load any .ts
// file other than those in src/, so we extend react's configuration,
// making it load *.ts file.
// const { CracoAliasPlugin } = require("react-app-alias");
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
const path = require("path");

// https://craco.js.org/docs/configuration/
module.exports = {
webpack: {
configure: (webpackConfig) => ({
...webpackConfig,
module: {
// 去掉 ModuleScopePluginc 插件, 解决如下报错:
// Module not found: Error: You attempted to import /Users/weidows/Desktop/PrivataFrontend/react-app/node_modules/.pnpm/[email protected]/node_modules/path-browserify/index.js which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
// You can either move it inside src/, or add a symlink to it from project's node_modules/.
configure: (webpackConfig) => {
const scopePluginIndex = webpackConfig.resolve.plugins.findIndex(
({ constructor }) =>
constructor && constructor.name === "ModuleScopePlugin"
);
webpackConfig.resolve.plugins.splice(scopePluginIndex, 1);

(webpackConfig.module = {
...webpackConfig.module,
rules: webpackConfig.module.rules.map((rule) => {
if (!rule.oneOf) return rule;
Expand All @@ -23,34 +34,57 @@ module.exports = {
}),
};
}),
},
resolve: {
...webpackConfig.resolve,
// 解决 Module not found
// If you want to include a polyfill, you need to:
// - add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
// - install 'path-browserify'
// If you don't want to include a polyfill, you can use an empty module like this:
// resolve.fallback: { "path": false }
fallback: {
...webpackConfig.resolve.fallback,
path: require.resolve("path-browserify"),
fs: require.resolve("fs"),
// tls: false,
// net: false,
// zlib: false,
// http: false,
// https: false,
// stream: false,
// crypto: false,
},
extensions: [".js", ".jsx", ".json", ".ts", ".tsx"],
// https://blog.csdn.net/peter_hzq/article/details/120656880
alias: {
"@": path.resolve(__dirname, "src"),
},
// modules: [webpackPaths.srcPath, "node_modules"],
},
}),
}),
(webpackConfig.resolve = {
...webpackConfig.resolve,
// 解决 Module not found
// If you want to include a polyfill, you need to:
// - add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
// - install 'path-browserify'
// If you don't want to include a polyfill, you can use an empty module like this:
// resolve.fallback: { "path": false }
fallback: {
...webpackConfig.resolve.fallback,
// 已经通过插件解决: NodePolyfillPlugin
// path: require.resolve("path-browserify"),
// path: false,
// fs: require.resolve("fs"),
// tls: false,
// net: false,
// zlib: false,
// http: false,
// https: false,
// stream: false,
// crypto: false,
},
extensions: [".js", ".jsx", ".json", ".ts", ".tsx"],
// https://blog.csdn.net/peter_hzq/article/details/120656880
// path 在 src 外很难导入
alias: {
"@": path.resolve(__dirname, "src"),
},
// modules: [webpackPaths.srcPath, "node_modules"],
});

return webpackConfig;
},

plugins: {
add: [
// new MonacoWebpackPlugin(),
// https://namespaceit.com/blog/how-fix-breaking-change-webpack-5-used-to-include-polyfills-for-nodejs-core-modules-by-default-error
new NodePolyfillPlugin(),
],
},
},
plugins: [
// {
// plugin: CracoAliasPlugin,
// options: {
// source: "tsconfig",
// baseUrl: ".",
// tsConfigPath: "./tsconfig.paths.json",
// },
// },
],
};
6 changes: 2 additions & 4 deletions react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"build": "craco build",
"test": "craco test",
"eject": "craco eject",
"lint": "eslint --ext .ts,.tsx .",
"prisma-generate": "prisma generate",
"prisma-migrate": "prisma migrate dev --name init",
"prisma-db-push": "prisma db push",
"jest-test": "jest",
"npm-check-update": "npm-check --skip-unused -u"
},
"eslintConfig": {
Expand Down Expand Up @@ -54,6 +54,7 @@
"@types/react-dom": "^18.0.0",
"axios": "^1.4.0",
"framer-motion": "^10.12.18",
"node-polyfill-webpack-plugin": "^3.0.0",
"path-browserify": "^1.0.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand All @@ -64,12 +65,9 @@
},
"devDependencies": {
"@craco/craco": "^7.1.0",
"@types/jest": "^29.5.5",
"@types/node": "^16.7.13",
"jest": "^29.7.0",
"prisma": "^5.5.2",
"tailwindcss": "^3.3.3",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1"
}
}
Loading