UglifyJS now invoked by webpack instead of Grunt

This commit is contained in:
n1474335 2017-03-23 18:41:36 +00:00
parent 131b3a83c1
commit 9bd11dc7ad
5 changed files with 5341 additions and 228 deletions

View file

@ -8,7 +8,7 @@ module.exports = function (grunt) {
// Tasks
grunt.registerTask("dev",
"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",
"Compiles CyberChef into a single NodeJS module.",
@ -20,8 +20,8 @@ module.exports = function (grunt) {
grunt.registerTask("prod",
"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",
"Compiles documentation in the /docs directory.",
@ -29,7 +29,7 @@ module.exports = function (grunt) {
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.",
["webpack:web", "uglify:prod", "exec:stats", "exec:repoSize", "exec:displayStats"]);
["webpack:webDev", "webpack:webProd", "exec:stats", "exec:repoSize", "exec:displayStats"]);
grunt.registerTask("release",
"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-webpack");
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks("grunt-contrib-cssmin");
grunt.loadNpmTasks("grunt-contrib-htmlmin");
grunt.loadNpmTasks("grunt-inline-alt");
@ -141,6 +140,7 @@ module.exports = function (grunt) {
COMPILE_TIME: JSON.stringify(compileTime),
COMPILE_MSG: JSON.stringify(grunt.option("compile-msg") || grunt.option("msg") || "")
}),
new ExtractTextPlugin("styles.css"),
],
resolve: {
alias: {
@ -154,24 +154,7 @@ module.exports = function (grunt) {
exclude: /node_modules/,
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: [
{
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: [
new ExtractTextPlugin("styles.css"),
new webpack.optimize.UglifyJsPlugin({
compress: {
"screw_ie8": true,
"dead_code": true,
"unused": true,
"warnings": false
},
comments: false,
}),
]
},
tests: {
@ -307,30 +314,6 @@ module.exports = function (grunt) {
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: {
prod: {
src: "build/dev/styles.css",
@ -444,11 +427,11 @@ module.exports = function (grunt) {
watch: {
css: {
files: ["src/web/css/**/*.css", "src/web/css/**/*.less"],
tasks: ["webpack:web", "chmod:build"]
tasks: ["webpack:webDev", "chmod:build"]
},
js: {
files: "src/**/*.js",
tasks: ["webpack:web", "chmod:build"]
tasks: ["webpack:webDev", "chmod:build"]
},
html: {
files: "src/web/html/**/*.html",
@ -460,7 +443,7 @@ module.exports = function (grunt) {
},
grunt: {
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 one or more lines are too long

File diff suppressed because one or more lines are too long

View file

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

View file

@ -4,10 +4,21 @@
* @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 Categories from "../core/config/Categories.js";
import OperationConfig from "../core/config/OperationConfig.js";
import CanvasComponents from "../core/lib/canvascomponents.js";
/**
* Main function used to build the CyberChef web app.