Procházet zdrojové kódy

upgrade package and config

RoyLiu před 5 roky
rodič
revize
4fba2f2d9e
9 změnil soubory, kde provedl 1897 přidání a 1787 odebrání
  1. 12 1
      .babelrc
  2. 3 1
      .eslintignore
  3. 12 1
      .eslintrc.js
  4. 1 5
      config/index.js
  5. 2 1
      i18n.js
  6. 13 0
      next.config.js
  7. 12 6
      package.json
  8. 2 0
      polyfills.js
  9. 1840 1772
      yarn.lock

+ 12 - 1
.babelrc

@@ -1,6 +1,17 @@
 {
   "presets": [
-    "next/babel"
+    [
+      "next/babel",
+      {
+        "preset-env": {
+          "targets": {
+            "ie": "11"
+          },
+          "corejs": "3",
+          "useBuiltIns": "entry"
+        }
+      }
+    ]
   ],
   "plugins": [
     ["inline-react-svg", {

+ 3 - 1
.eslintignore

@@ -1,4 +1,6 @@
 **/node_modules/**
 **/static/**
 **/__mocks__/**
-**/next-env.d.ts
+**/next-env.d.ts
+**/polyfill.js
+**/next.config.js

+ 12 - 1
.eslintrc.js

@@ -26,8 +26,19 @@ module.exports = {
   "rules": {
     "no-console": "off",
     "react/jsx-filename-extension": [2, { extensions: ['.js', '.jsx', '.ts', '.tsx'] }],
-    "camelcase": [0, {properties: "never"}],
+    "camelcase": "off",
+    "@typescript-eslint/camelcase": [0, { "properties": "never" }],
     "@typescript-eslint/no-explicit-any": 0,
     "@typescript-eslint/ban-ts-ignore": 0,
+    "import/extensions": [
+      "error",
+      "ignorePackages",
+      {
+        "js": "never",
+        "jsx": "never",
+        "ts": "never",
+        "tsx": "never"
+      }
+   ]
   }
 };

+ 1 - 5
config/index.js

@@ -1,13 +1,9 @@
-let API_HOST = 'http://localhost:3000';
+let API_HOST = 'http://192.168.173.26:3000';
 
 switch (process.env.NODE_ENV) {
   case 'production':
     API_HOST = '';
     break;
-  case 'preparing':
-  case 'test':
-    API_HOST = 'http://localhost:3000';
-    break;
   default:
     break;
 }

+ 2 - 1
i18n.js

@@ -8,7 +8,8 @@ const NextI18NextInstance = new NextI18Next({
   },
   defaultLanguage: 'en',
   otherLanguages: ['zh-tw'],
-  ignoreRoutes: ['/_next/', '/static/', '/public/'],
+  ignoreRoutes: ['/_next/', '/public/'],
+  localePath: 'public/locales',
 });
 
 module.exports = NextI18NextInstance;

+ 13 - 0
next.config.js

@@ -4,6 +4,19 @@ const withTM = require('next-transpile-modules');
 module.exports = withTM({
   transpileModules: ['query-string', 'split-on-first', 'strict-uri-encode'],
   webpack: (config) => {
+    const originalEntry = config.entry;
+
+    config.entry = async () => {
+      const entries = await originalEntry();
+      if (
+        entries['main.js'] &&
+        !entries['main.js'].includes('./polyfills.js')
+      ) {
+        entries['main.js'].unshift('./polyfills.js')
+      }
+      return entries;
+    };
+
     config.plugins.push(
       new webpack.DefinePlugin({
         'process.env.ENV': JSON.stringify(process.env.ENV),

+ 12 - 6
package.json

@@ -4,8 +4,8 @@
   "scripts": {
     "dev": "next -p 8080",
     "build": "next build",
-    "start": "next start",
-    "export": "npm run build && next export",
+    "start": "next start -p 8080",
+    "export": "NODE_ENV=production ENV=production npm run build && next export",
     "lint": "eslint . --ext .ts,.tsx",
     "test": "jest --config=./config/jest.config.js"
   },
@@ -13,17 +13,22 @@
     "lint"
   ],
   "dependencies": {
+    "@babel/core": "^7.8.4",
+    "@babel/polyfill": "^7.8.3",
     "@material-ui/core": "^4.6.1",
+    "@types/lodash": "^4.14.149",
     "babel-plugin-inline-react-svg": "^1.1.0",
+    "core-js": "3.6.4",
     "immer": "^5.0.0",
     "isomorphic-unfetch": "^3.0.0",
     "js-cookie": "^2.2.0",
+    "lodash": "^4.17.15",
     "mobile-detect": "^1.4.3",
-    "next": "9.1.6",
-    "next-i18next": "^2.0.0",
+    "next": "9.2.1",
+    "next-i18next": "4.1.0",
     "next-transpile-modules": "^2.3.1",
     "notistack": "^0.9.6",
-    "pdfjs-dist": "^2.2.228",
+    "pdfjs-dist": "2.3.200",
     "prop-types": "^15.6.2",
     "query-string": "^6.9.0",
     "react": "16.10.0",
@@ -31,12 +36,13 @@
     "react-popper": "^1.3.6",
     "redux-devtools-extension": "^2.13.5",
     "rxjs": "^6.5.3",
-    "styled-components": "4.4.0",
+    "styled-components": "5.0.0",
     "webpack": "^4.41.2"
   },
   "license": "MIT",
   "devDependencies": {
     "@babel/node": "^7.2.2",
+    "@babel/preset-env": "^7.8.3",
     "@testing-library/jest-dom": "^4.2.3",
     "@testing-library/react": "^9.3.2",
     "@types/jest": "^24.0.23",

+ 2 - 0
polyfills.js

@@ -0,0 +1,2 @@
+import '@babel/polyfill';
+import 'core-js/modules/es.promise';

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1840 - 1772
yarn.lock