Prechádzať zdrojové kódy

20230217: Migrated webpack5 configuration from Pioneer project

mkbeefcake 1 rok pred
rodič
commit
4fc9c2e8b1
6 zmenil súbory, kde vykonal 75 pridanie a 17 odobranie
  1. 0 4
      .babelrc
  2. 12 0
      babel.config.js
  3. 6 0
      package.json
  4. 11 3
      tsconfig.json
  5. 23 6
      webpack.config.js
  6. 23 4
      yarn.lock

+ 0 - 4
.babelrc

@@ -1,4 +0,0 @@
-{
-    "presets": ["@babel/react", "@babel/env"],
-    "plugins": ["@babel/plugin-proposal-class-properties"]
-  }

+ 12 - 0
babel.config.js

@@ -0,0 +1,12 @@
+// babel.config.js
+module.exports = {
+  presets: [
+    ['@babel/preset-env', { targets: { node: 'current' } }], 
+    '@babel/preset-typescript', 
+    '@babel/preset-react'
+  ],
+  plugins: [
+    ['babel-plugin-import-graphql', { runtime: true }],
+    ['babel-plugin-styled-components', { displayName: true, fileName: false }],
+  ],
+}

+ 6 - 0
package.json

@@ -64,6 +64,9 @@
   "devDependencies": {
     "@babel/core": "^7.20.12",
     "@babel/plugin-proposal-class-properties": "^7.18.6",
+    "@babel/preset-env": "^7.20.2",
+    "@babel/preset-react": "^7.18.6",
+    "@babel/preset-typescript": "^7.18.6",
     "@types/bootstrap": "^5.0.1",
     "@types/jest": "^26.0.15",
     "@types/node": "^12.0.0",
@@ -76,12 +79,15 @@
     "@types/react-dom": "^16.9.8",
     "@types/react-router-dom": "^5.1.6",
     "@types/styled-components": "^5.1.12",
+    "babel-plugin-import-graphql": "^2.8.1",
+    "babel-plugin-styled-components": "^2.0.7",
     "babel-preset-env": "^1.7.0",
     "babel-preset-react": "^6.24.1",
     "crypto-browserify": "^3.12.0",
     "css-loader": "^6.7.3",
     "file-loader": "^6.2.0",
     "html-webpack-plugin": "^5.5.0",
+    "path-browserify": "^1.0.1",
     "raw-loader": "^4.0.2",
     "stream-browserify": "^3.0.0",
     "style-loader": "^3.3.1",

+ 11 - 3
tsconfig.json

@@ -1,17 +1,25 @@
 {
+  "ts-node": {
+    "files": false
+  },
   "include": [
       "src/*"
   ],
   "compilerOptions": {
-      "target": "ESNext",
-      "lib": ["ESNext", "DOM"],
+      "target": "es2020",
+      "lib": ["ES2020", "DOM"],
       "module": "commonJS",
       "jsx": "react",
+      "sourceMap": true,
+      "strict": true,
       "allowSyntheticDefaultImports": true,
       "esModuleInterop": true,
+      "resolveJsonModule": true,
+      "skipLibCheck": true,
       "rootDir": "./src/",
+      "baseUrl": ".",
       "paths": {
-        "./*": ["./*", "./src/*"]
+        "./*": ["./node_modules/*", "./src/*"]
       }
   },
   "exclude": [

+ 23 - 6
webpack.config.js

@@ -1,4 +1,5 @@
 const path = require('path');
+const webpack = require('webpack')
 const HtmlWebpackPlugin = require('html-webpack-plugin');
 
 const { DEV, DEBUG } = process.env;
@@ -20,11 +21,18 @@ module.exports = {
             {
                 test: /\.(js|jsx)$/,
                 exclude: /node_modules/,
-                loader: 'babel-loader',
+                type: 'javascript/auto',
             },
             {
                 test: /\.tsx?$/,
-                loader: 'ts-loader',
+                use: [
+                  {
+                    loader: 'ts-loader',
+                    options: {
+                      transpileOnly: true,
+                    },
+                  },
+                ],
                 exclude: [/node_modules/],
             },
             {
@@ -85,13 +93,22 @@ module.exports = {
         fallback: {
             crypto: require.resolve('crypto-browserify'),
             stream: require.resolve('stream-browserify'),
-            path: false,
+            path: require.resolve("path-browserify"),
             fs: false,
-        }
-    },
+        },
+        // alias: {
+        //   '@': path.resolve(__dirname, './src/'),
+        //   'react/jsx-runtime': require.resolve('react/jsx-runtime'),
+        // },
+      },
     plugins:[
         new HtmlWebpackPlugin({
             template: path.join(__dirname,'/public/index.html')
-        }) 
+        }),
+        new webpack.ProvidePlugin({
+          Buffer: ['buffer', 'Buffer'],
+          process: 'process/browser.js',
+          "React": "react",
+        }),      
     ]
 }

+ 23 - 4
yarn.lock

@@ -929,7 +929,7 @@
     "@babel/helper-create-regexp-features-plugin" "^7.18.6"
     "@babel/helper-plugin-utils" "^7.18.6"
 
-"@babel/preset-env@^7.16.4", "@babel/preset-env@^7.8.4", "@babel/preset-env@^7.9.5":
+"@babel/preset-env@^7.16.4", "@babel/preset-env@^7.20.2", "@babel/preset-env@^7.8.4", "@babel/preset-env@^7.9.5":
   version "7.20.2"
   resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.20.2.tgz#9b1642aa47bb9f43a86f9630011780dab7f86506"
   integrity sha512-1G0efQEWR1EHkKvKHqbG+IN/QdgwfByUpM5V5QroDzGV2t3S/WXNQd693cHiHTlCFMpr9B6FkPFXDA2lQcKoDg==
@@ -1021,7 +1021,7 @@
     "@babel/types" "^7.4.4"
     esutils "^2.0.2"
 
-"@babel/preset-react@^7.16.0", "@babel/preset-react@^7.9.4":
+"@babel/preset-react@^7.16.0", "@babel/preset-react@^7.18.6", "@babel/preset-react@^7.9.4":
   version "7.18.6"
   resolved "https://registry.yarnpkg.com/@babel/preset-react/-/preset-react-7.18.6.tgz#979f76d6277048dc19094c217b507f3ad517dd2d"
   integrity sha512-zXr6atUmyYdiWRVLOZahakYmOBHtWc2WGCkP8PYTgZi0iJXDY2CN180TdrIW4OGOAdLc7TifzDIvtx6izaRIzg==
@@ -1033,7 +1033,7 @@
     "@babel/plugin-transform-react-jsx-development" "^7.18.6"
     "@babel/plugin-transform-react-pure-annotations" "^7.18.6"
 
-"@babel/preset-typescript@^7.16.0":
+"@babel/preset-typescript@^7.16.0", "@babel/preset-typescript@^7.18.6":
   version "7.18.6"
   resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.18.6.tgz#ce64be3e63eddc44240c6358daefac17b3186399"
   integrity sha512-s9ik86kXBAnD760aybBucdpnLsAt0jK1xqJn2juOn9lkOvSHV60os5hxoVJsPzMQxvnUJFAlkont2DvvaYEBtQ==
@@ -3843,6 +3843,13 @@ babel-plugin-check-es2015-constants@^6.22.0:
   dependencies:
     babel-runtime "^6.22.0"
 
+babel-plugin-import-graphql@^2.8.1:
+  version "2.8.1"
+  resolved "https://registry.yarnpkg.com/babel-plugin-import-graphql/-/babel-plugin-import-graphql-2.8.1.tgz#dec677dc47327181d69e8c451aff290460ca2ed6"
+  integrity sha512-j8Y0rWfMCd7Q63+hzCENrzbwYvQ9GfRbD3S50oHJ0SmEeRRVgLMxj+jXCBVLTFlmFLzY8UYVQQGx3FgrK3wajA==
+  dependencies:
+    graphql-tag "^2.9.2"
+
 babel-plugin-istanbul@^6.0.0:
   version "6.1.1"
   resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-6.1.1.tgz#fa88ec59232fd9b4e36dbbc540a8ec9a9b47da73"
@@ -3902,7 +3909,7 @@ babel-plugin-polyfill-regenerator@^0.4.1:
   dependencies:
     "@babel/helper-define-polyfill-provider" "^0.3.3"
 
-"babel-plugin-styled-components@>= 1.12.0":
+"babel-plugin-styled-components@>= 1.12.0", babel-plugin-styled-components@^2.0.7:
   version "2.0.7"
   resolved "https://registry.yarnpkg.com/babel-plugin-styled-components/-/babel-plugin-styled-components-2.0.7.tgz#c81ef34b713f9da2b7d3f5550df0d1e19e798086"
   integrity sha512-i7YhvPgVqRKfoQ66toiZ06jPNA3p6ierpfUuEWxNF+fV27Uv5gxBkf8KZLHUCc1nFA9j6+80pYoIpqCeyW3/bA==
@@ -7585,6 +7592,13 @@ graceful-fs@~3.0.4:
   dependencies:
     natives "^1.1.3"
 
+graphql-tag@^2.9.2:
+  version "2.12.6"
+  resolved "https://registry.yarnpkg.com/graphql-tag/-/graphql-tag-2.12.6.tgz#d441a569c1d2537ef10ca3d1633b48725329b5f1"
+  integrity sha512-FdSNcu2QQcWnM2VNvSCCDCVS5PpPqpzgFT8+GXzqJuoDd0CBncxCY278u4mhRO7tMgo2JjgJA5aZ+nWSQ/Z+xg==
+  dependencies:
+    tslib "^2.1.0"
+
 growly@^1.3.0:
   version "1.3.0"
   resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081"
@@ -10957,6 +10971,11 @@ path-browserify@0.0.1:
   resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-0.0.1.tgz#e6c4ddd7ed3aa27c68a20cc4e50e1a4ee83bbc4a"
   integrity sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ==
 
+path-browserify@^1.0.1:
+  version "1.0.1"
+  resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-1.0.1.tgz#d98454a9c3753d5790860f16f68867b9e46be1fd"
+  integrity sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==
+
 path-dirname@^1.0.0:
   version "1.0.2"
   resolved "https://registry.yarnpkg.com/path-dirname/-/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0"