Browse Source

UglifyJS now invoked by webpack instead of Grunt

n1474335 8 years ago
parent
commit
9bd11dc7ad
5 changed files with 46 additions and 73 deletions
  1. 34 51
      Gruntfile.js
  2. 0 20
      build/prod/scripts.js
  3. 0 0
      build/prod/styles.css
  4. 0 1
      package.json
  5. 12 1
      src/web/index.js

+ 34 - 51
Gruntfile.js

@@ -8,7 +8,7 @@ module.exports = function (grunt) {
     // Tasks
     // Tasks
     grunt.registerTask("dev",
     grunt.registerTask("dev",
         "A persistent task which creates a development build whenever source files are modified.",
         "A persistent task which creates a development build whenever source files are modified.",
-        ["clean:dev", "webpack:web", "copy:htmlDev", "copy:staticDev", "chmod:build", "watch"]);
+        ["clean:dev", "copy:htmlDev", "copy:staticDev", "chmod:build", "webpack:webDev", "watch"]);
 
 
     grunt.registerTask("node",
     grunt.registerTask("node",
         "Compiles CyberChef into a single NodeJS module.",
         "Compiles CyberChef into a single NodeJS module.",
@@ -20,8 +20,8 @@ module.exports = function (grunt) {
 
 
     grunt.registerTask("prod",
     grunt.registerTask("prod",
         "Creates a production-ready build. Use the --msg flag to add a compile message.",
         "Creates a production-ready build. Use the --msg flag to add a compile message.",
-        ["eslint", "test", "exec:stats", "clean", "jsdoc", "webpack:web", "copy:htmlDev", "copy:htmlProd", "copy:htmlInline",
-         "copy:staticDev", "copy:staticProd", "cssmin", "uglify:prod", "inline", "htmlmin", "chmod"]);
+        ["eslint", "test", "exec:stats", "clean", "jsdoc", "webpack:webProd", "copy:htmlDev", "copy:htmlProd", "copy:htmlInline",
+         "copy:staticDev", "copy:staticProd", "cssmin", "inline", "htmlmin", "chmod"]);
 
 
     grunt.registerTask("docs",
     grunt.registerTask("docs",
         "Compiles documentation in the /docs directory.",
         "Compiles documentation in the /docs directory.",
@@ -29,7 +29,7 @@ module.exports = function (grunt) {
 
 
     grunt.registerTask("stats",
     grunt.registerTask("stats",
         "Provides statistics about the code base such as how many lines there are as well as details of file sizes before and after compression.",
         "Provides statistics about the code base such as how many lines there are as well as details of file sizes before and after compression.",
-        ["webpack:web", "uglify:prod", "exec:stats", "exec:repoSize", "exec:displayStats"]);
+        ["webpack:webDev", "webpack:webProd", "exec:stats", "exec:repoSize", "exec:displayStats"]);
 
 
     grunt.registerTask("release",
     grunt.registerTask("release",
         "Prepares and deploys a production version of CyberChef to the gh-pages branch.",
         "Prepares and deploys a production version of CyberChef to the gh-pages branch.",
@@ -50,7 +50,6 @@ module.exports = function (grunt) {
     grunt.loadNpmTasks("grunt-contrib-clean");
     grunt.loadNpmTasks("grunt-contrib-clean");
     grunt.loadNpmTasks("grunt-webpack");
     grunt.loadNpmTasks("grunt-webpack");
     grunt.loadNpmTasks("grunt-contrib-copy");
     grunt.loadNpmTasks("grunt-contrib-copy");
-    grunt.loadNpmTasks("grunt-contrib-uglify");
     grunt.loadNpmTasks("grunt-contrib-cssmin");
     grunt.loadNpmTasks("grunt-contrib-cssmin");
     grunt.loadNpmTasks("grunt-contrib-htmlmin");
     grunt.loadNpmTasks("grunt-contrib-htmlmin");
     grunt.loadNpmTasks("grunt-inline-alt");
     grunt.loadNpmTasks("grunt-inline-alt");
@@ -141,6 +140,7 @@ module.exports = function (grunt) {
                         COMPILE_TIME: JSON.stringify(compileTime),
                         COMPILE_TIME: JSON.stringify(compileTime),
                         COMPILE_MSG: JSON.stringify(grunt.option("compile-msg") || grunt.option("msg") || "")
                         COMPILE_MSG: JSON.stringify(grunt.option("compile-msg") || grunt.option("msg") || "")
                     }),
                     }),
+                    new ExtractTextPlugin("styles.css"),
                 ],
                 ],
                 resolve: {
                 resolve: {
                     alias: {
                     alias: {
@@ -154,24 +154,7 @@ module.exports = function (grunt) {
                             exclude: /node_modules/,
                             exclude: /node_modules/,
                             loader: "babel-loader?compact=false"
                             loader: "babel-loader?compact=false"
                         }
                         }
-                    ]
-                }
-            },
-            web: {
-                target: "web",
-                entry: [
-                    "babel-polyfill",
-                    "bootstrap",
-                    "bootstrap-switch",
-                    "bootstrap-colorpicker",
-                    "./src/web/css/index.js",
-                    "./src/web/index.js"
-                ],
-                output: {
-                    filename: "scripts.js",
-                    path: "build/dev"
-                },
-                module: {
+                    ],
                     rules: [
                     rules: [
                         {
                         {
                             test: /\.css$/,
                             test: /\.css$/,
@@ -196,9 +179,33 @@ module.exports = function (grunt) {
                             }
                             }
                         }
                         }
                     ]
                     ]
+                }
+            },
+            webDev: {
+                target: "web",
+                entry: "./src/web/index.js",
+                output: {
+                    filename: "scripts.js",
+                    path: "build/dev"
+                }
+            },
+            webProd: {
+                target: "web",
+                entry: "./src/web/index.js",
+                output: {
+                    filename: "scripts.js",
+                    path: "build/prod"
                 },
                 },
                 plugins: [
                 plugins: [
-                    new ExtractTextPlugin("styles.css"),
+                    new webpack.optimize.UglifyJsPlugin({
+                        compress: {
+                            "screw_ie8": true,
+                            "dead_code": true,
+                            "unused": true,
+                            "warnings": false
+                        },
+                        comments: false,
+                    }),
                 ]
                 ]
             },
             },
             tests: {
             tests: {
@@ -307,30 +314,6 @@ module.exports = function (grunt) {
                 dest: "build/prod/index.html"
                 dest: "build/prod/index.html"
             }
             }
         },
         },
-        uglify: {
-            options: {
-                preserveComments: function (node, comment) {
-                    if (comment.value.indexOf("* @license") === 0) return true;
-                    return false;
-                },
-                screwIE8: true,
-                ASCIIOnly: true,
-                beautify: {
-                    beautify: false,
-                    inline_script: true, // eslint-disable-line camelcase
-                    ascii_only: true, // eslint-disable-line camelcase
-                    screw_ie8: true // eslint-disable-line camelcase
-                },
-                compress: {
-                    screw_ie8: true // eslint-disable-line camelcase
-                },
-                banner: banner
-            },
-            prod: {
-                src: "build/dev/scripts.js",
-                dest: "build/prod/scripts.js"
-            }
-        },
         cssmin: {
         cssmin: {
             prod: {
             prod: {
                 src: "build/dev/styles.css",
                 src: "build/dev/styles.css",
@@ -444,11 +427,11 @@ module.exports = function (grunt) {
         watch: {
         watch: {
             css: {
             css: {
                 files: ["src/web/css/**/*.css", "src/web/css/**/*.less"],
                 files: ["src/web/css/**/*.css", "src/web/css/**/*.less"],
-                tasks: ["webpack:web", "chmod:build"]
+                tasks: ["webpack:webDev", "chmod:build"]
             },
             },
             js: {
             js: {
                 files: "src/**/*.js",
                 files: "src/**/*.js",
-                tasks: ["webpack:web", "chmod:build"]
+                tasks: ["webpack:webDev", "chmod:build"]
             },
             },
             html: {
             html: {
                 files: "src/web/html/**/*.html",
                 files: "src/web/html/**/*.html",
@@ -460,7 +443,7 @@ module.exports = function (grunt) {
             },
             },
             grunt: {
             grunt: {
                 files: "Gruntfile.js",
                 files: "Gruntfile.js",
-                tasks: ["clean:dev", "webpack:web", "copy:htmlDev", "copy:staticDev", "chmod:build"]
+                tasks: ["clean:dev", "webpack:webDev", "copy:htmlDev", "copy:staticDev", "chmod:build"]
             }
             }
         },
         },
     });
     });

File diff suppressed because it is too large
+ 0 - 20
build/prod/scripts.js


File diff suppressed because it is too large
+ 0 - 0
build/prod/styles.css


+ 0 - 1
package.json

@@ -40,7 +40,6 @@
     "grunt-contrib-copy": "~1.0.0",
     "grunt-contrib-copy": "~1.0.0",
     "grunt-contrib-cssmin": "~1.0.2",
     "grunt-contrib-cssmin": "~1.0.2",
     "grunt-contrib-htmlmin": "~2.0.0",
     "grunt-contrib-htmlmin": "~2.0.0",
-    "grunt-contrib-uglify": "~2.0.0",
     "grunt-contrib-watch": "~1.0.0",
     "grunt-contrib-watch": "~1.0.0",
     "grunt-eslint": "^19.0.0",
     "grunt-eslint": "^19.0.0",
     "grunt-exec": "~1.0.1",
     "grunt-exec": "~1.0.1",

+ 12 - 1
src/web/index.js

@@ -4,10 +4,21 @@
  * @license Apache-2.0
  * @license Apache-2.0
  */
  */
 
 
+// CSS
+import "./css/index.js";
+
+// Libs
+import "babel-polyfill";
+import "bootstrap";
+import "bootstrap-switch";
+import "bootstrap-colorpicker";
+import CanvasComponents from "../core/lib/canvascomponents.js";
+
+// CyberChef
 import App from "./App.js";
 import App from "./App.js";
 import Categories from "../core/config/Categories.js";
 import Categories from "../core/config/Categories.js";
 import OperationConfig from "../core/config/OperationConfig.js";
 import OperationConfig from "../core/config/OperationConfig.js";
-import CanvasComponents from "../core/lib/canvascomponents.js";
+
 
 
 /**
 /**
  * Main function used to build the CyberChef web app.
  * Main function used to build the CyberChef web app.

Some files were not shown because too many files changed in this diff