Răsfoiți Sursa

Webpack fixes

Dmitrii Selivanov 3 ani în urmă
părinte
comite
a43811f2d7
3 a modificat fișierele cu 932 adăugiri și 98 ștergeri
  1. 884 61
      package-lock.json
  2. 3 2
      package.json
  3. 45 35
      webpack.config.js

Fișier diff suprimat deoarece este prea mare
+ 884 - 61
package-lock.json


+ 3 - 2
package.json

@@ -5,8 +5,8 @@
   "main": "ryd.content-script.js",
   "scripts": {
     "start": "echo To build for development, please use \"npm run dev\". To build for production, please use \"npm run build\".",
-    "dev": "webpack --mode=development \"./Extensions/combined/ryd.content-script.js\" -o \"./Extensions/combined/dist/\" --watch",
-    "build": "webpack --mode=production \"./Extensions/combined/ryd.content-script.js\" -o \"./Extensions/combined\"",
+    "dev": "webpack --mode=production --watch",
+    "build": "webpack --mode=production",
     "test": "echo \"Error: no test specified\" && exit 1"
   },
   "repository": {
@@ -30,6 +30,7 @@
     "@babel/runtime": "^7.16.5",
     "babel-loader": "^8.2.3",
     "copy-webpack-plugin": "^10.2.0",
+    "filemanager-webpack-plugin": "^6.1.7",
     "webpack-cli": "^4.9.1"
   }
 }

+ 45 - 35
webpack.config.js

@@ -1,57 +1,67 @@
-const path = require('path');
-const CopyPlugin = require('copy-webpack-plugin');
+const path = require("path");
+const CopyPlugin = require("copy-webpack-plugin");
+const FileManagerPlugin = require("filemanager-webpack-plugin");
 
 module.exports = {
-  entry: path.join(__dirname, './Extensions/combined/ryd.content-script.js'),
+  entry: path.join(__dirname, "./Extensions/combined/ryd.content-script.js"),
   output: {
-    filename: 'bundled-content-script.js',
-    path: path.resolve(__dirname, 'Extensions/combined')
+    filename: "bundled-content-script.js",
+    path: path.resolve(__dirname, "Extensions/combined/dist"),
+    clean: true,
   },
   optimization: {
-    minimize: false
+    minimize: false,
   },
-  module: {
-    rules: [
-      {
-        test: /\.m?js$/,
-        exclude: /(node_modules|bower_components)/,
-        use: {
-          loader: 'babel-loader',
-          options: {
-            presets: ['@babel/preset-env'],
-            plugins: ['@babel/plugin-proposal-object-rest-spread']
-          }
-        }
-      }
-    ]
+  watchOptions: {
+    ignored: "./Extensions/combined/dist/*"
   },
   plugins: [
     // exclude locale files in moment
     new CopyPlugin({
       patterns: [
         {
-          from: './Extensions/combined',
-          to: './dist/chrome',
+          from: "./Extensions/combined",
+          to: "./chrome",
           globOptions: {
-            ignore: ['**/manifest-**', '**/dist/**', '**/src/**','**/ryd.content-script.js']
-          }
+            ignore: [
+              "**/manifest-**",
+              "**/dist/**",
+              "**/src/**",
+              "**/ryd.content-script.js",
+            ],
+          },
         },
         {
-          from: './Extensions/combined/manifest-chrome.json',
-          to: './dist/chrome/manifest.json'
+          from: "./Extensions/combined/manifest-chrome.json",
+          to: "./chrome/manifest.json",
         },
         {
-          from: './Extensions/combined',
-          to: './dist/firefox',
+          from: "./Extensions/combined",
+          to: "./firefox",
           globOptions: {
-            ignore: ['**/manifest-**', '**/dist/**', '**/src/**','**/ryd.content-script.js']
-          }
+            ignore: [
+              "**/manifest-**",
+              "**/dist/**",
+              "**/src/**",
+              "**/ryd.content-script.js",
+            ],
+          },
         },
         {
-          from: './Extensions/combined/manifest-firefox.json',
-          to: './dist/firefox/manifest.json'
+          from: "./Extensions/combined/manifest-firefox.json",
+          to: "./firefox/manifest.json",
         }
-      ]
-    })
-  ]
+      ],
+    }),
+    new FileManagerPlugin({
+      events: {
+        onEnd: {
+          copy: [
+            { source: "./Extensions/combined/dist/bundled-content-script.js", destination: "./Extensions/combined/dist/firefox/bundled-content-script.js" },
+            { source: "./Extensions/combined/dist/bundled-content-script.js", destination: "./Extensions/combined/dist/chrome/bundled-content-script.js" },
+          ],
+        },
+      },
+    }),
+  ],
 };

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff