Explorar o código

prod working with mini css webpack plugin

d98762625 %!s(int64=6) %!d(string=hai) anos
pai
achega
a7a2fe243a
Modificáronse 2 ficheiros con 11 adicións e 23 borrados
  1. 3 0
      Gruntfile.js
  2. 8 23
      src/web/RecipeWaiter.mjs

+ 3 - 0
Gruntfile.js

@@ -300,6 +300,9 @@ module.exports = function (grunt) {
                             "./config/modules/OpModules": "./config/modules/Default"
                         }
                     },
+                    output: {
+                        globalObject: "this",
+                    },
                     plugins: [
                         new webpack.DefinePlugin(BUILD_CONSTANTS),
                         new HtmlWebpackPlugin({

+ 8 - 23
src/web/RecipeWaiter.mjs

@@ -563,35 +563,20 @@ class RecipeWaiter {
             this.ingredientChildRuleID = null;
 
             // Find relevant rules in the stylesheet
-            // try {
-            if (document.styleSheets[0].hasOwnProperty("cssRules")) {
-                for (const i in document.styleSheets[0].cssRules) {
-                    if (document.styleSheets[0].cssRules[i].selectorText === ".ingredients") {
-                        this.ingredientRuleID = i;
-                    }
-                    if (document.styleSheets[0].cssRules[i].selectorText === ".ingredients > div") {
-                        this.ingredientChildRuleID = i;
-                    }
+            for (const i in document.styleSheets[0].cssRules) {
+                if (document.styleSheets[0].cssRules[i].selectorText === ".ingredients") {
+                    this.ingredientRuleID = i;
+                }
+                if (document.styleSheets[0].cssRules[i].selectorText === ".ingredients > div") {
+                    this.ingredientChildRuleID = i;
                 }
             }
-            // } catch (e) {
-            //     console.log(e.constructor);
-            //     console.warn("Can't read the css rules of: " + document.styleSheets[0], e);
-            // }
         }
 
         if (!this.ingredientRuleID || !this.ingredientChildRuleID) return;
-        let ingredientRule, ingredientChildRule;
 
-        // Chrome 64+
-        // try {
-        if (document.styleSheets[0].hasOwnProperty("cssRules")) {
-            ingredientRule = document.styleSheets[0].cssRules[this.ingredientRuleID];
-            ingredientChildRule = document.styleSheets[0].cssRules[this.ingredientChildRuleID];
-        }
-        // } catch (e) {
-        //     console.warn("Can't read the css rules of: " + document.styleSheets[0], e);
-        // }
+        const ingredientRule = document.styleSheets[0].cssRules[this.ingredientRuleID];
+        const ingredientChildRule = document.styleSheets[0].cssRules[this.ingredientChildRuleID];
 
         if (recList.clientWidth < 450) {
             ingredientRule.style.gridTemplateColumns = "auto auto";