mirror of
https://github.com/gchq/CyberChef
synced 2024-12-26 04:23:10 +00:00
Configured webpack-dev-server
This commit is contained in:
parent
8eb7d65b74
commit
ff78c72d54
4 changed files with 156 additions and 124 deletions
166
Gruntfile.js
166
Gruntfile.js
|
@ -1,8 +1,15 @@
|
||||||
const webpack = require("webpack");
|
const webpack = require("webpack");
|
||||||
const ExtractTextPlugin = require("extract-text-webpack-plugin");
|
|
||||||
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
||||||
const Inliner = require("web-resource-inliner");
|
const Inliner = require("web-resource-inliner");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Grunt configuration for building the app in various formats.
|
||||||
|
*
|
||||||
|
* @author n1474335 [n1474335@gmail.com]
|
||||||
|
* @copyright Crown Copyright 2017
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
module.exports = function (grunt) {
|
module.exports = function (grunt) {
|
||||||
grunt.file.defaultEncoding = "utf8";
|
grunt.file.defaultEncoding = "utf8";
|
||||||
grunt.file.preserveBOM = false;
|
grunt.file.preserveBOM = false;
|
||||||
|
@ -10,7 +17,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:webDev"]);
|
["clean:dev", "webpack-dev-server:start"]);
|
||||||
|
|
||||||
grunt.registerTask("node",
|
grunt.registerTask("node",
|
||||||
"Compiles CyberChef into a single NodeJS module.",
|
"Compiles CyberChef into a single NodeJS module.",
|
||||||
|
@ -26,7 +33,7 @@ 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", "clean:prod", "webpack:webProd", "inline", "chmod"]);
|
["eslint", "clean:prod", "webpack:web", "inline", "chmod"]);
|
||||||
|
|
||||||
grunt.registerTask("default",
|
grunt.registerTask("default",
|
||||||
"Lints the code base",
|
"Lints the code base",
|
||||||
|
@ -55,27 +62,13 @@ module.exports = function (grunt) {
|
||||||
|
|
||||||
// Project configuration
|
// Project configuration
|
||||||
const compileTime = grunt.template.today("UTC:dd/mm/yyyy HH:MM:ss") + " UTC",
|
const compileTime = grunt.template.today("UTC:dd/mm/yyyy HH:MM:ss") + " UTC",
|
||||||
banner = "/**\n" +
|
pkg = grunt.file.readJSON("package.json"),
|
||||||
"* CyberChef - The Cyber Swiss Army Knife\n" +
|
webpackConfig = require("./webpack.config.js"),
|
||||||
"*\n" +
|
BUILD_CONSTANTS = {
|
||||||
"* @copyright Crown Copyright 2016\n" +
|
COMPILE_TIME: JSON.stringify(compileTime),
|
||||||
"* @license Apache-2.0\n" +
|
COMPILE_MSG: JSON.stringify(grunt.option("compile-msg") || grunt.option("msg") || ""),
|
||||||
"*\n" +
|
PKG_VERSION: JSON.stringify(pkg.version)
|
||||||
"* Copyright 2016 Crown Copyright\n" +
|
};
|
||||||
"*\n" +
|
|
||||||
'* Licensed under the Apache License, Version 2.0 (the "License");\n' +
|
|
||||||
"* you may not use this file except in compliance with the License.\n" +
|
|
||||||
"* You may obtain a copy of the License at\n" +
|
|
||||||
"*\n" +
|
|
||||||
"* http://www.apache.org/licenses/LICENSE-2.0\n" +
|
|
||||||
"*\n" +
|
|
||||||
"* Unless required by applicable law or agreed to in writing, software\n" +
|
|
||||||
'* distributed under the License is distributed on an "AS IS" BASIS,\n' +
|
|
||||||
"* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" +
|
|
||||||
"* See the License for the specific language governing permissions and\n" +
|
|
||||||
"* limitations under the License.\n" +
|
|
||||||
"*/\n",
|
|
||||||
pkg = grunt.file.readJSON("package.json");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiles a production build of CyberChef into a single, portable web page.
|
* Compiles a production build of CyberChef into a single, portable web page.
|
||||||
|
@ -150,104 +143,8 @@ module.exports = function (grunt) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
webpack: {
|
webpack: {
|
||||||
options: {
|
options: webpackConfig,
|
||||||
plugins: [
|
web: {
|
||||||
new webpack.ProvidePlugin({
|
|
||||||
$: "jquery",
|
|
||||||
jQuery: "jquery",
|
|
||||||
moment: "moment-timezone"
|
|
||||||
}),
|
|
||||||
new webpack.BannerPlugin({
|
|
||||||
banner: banner,
|
|
||||||
raw: true,
|
|
||||||
entryOnly: true
|
|
||||||
}),
|
|
||||||
new webpack.DefinePlugin({
|
|
||||||
COMPILE_TIME: JSON.stringify(compileTime),
|
|
||||||
COMPILE_MSG: JSON.stringify(grunt.option("compile-msg") || grunt.option("msg") || ""),
|
|
||||||
PKG_VERSION: JSON.stringify(pkg.version)
|
|
||||||
}),
|
|
||||||
new ExtractTextPlugin("styles.css"),
|
|
||||||
],
|
|
||||||
resolve: {
|
|
||||||
alias: {
|
|
||||||
jquery: "jquery/src/jquery"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
test: /\.js$/,
|
|
||||||
exclude: /node_modules/,
|
|
||||||
loader: "babel-loader?compact=false"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.css$/,
|
|
||||||
use: ExtractTextPlugin.extract({
|
|
||||||
use: [
|
|
||||||
{ loader: "css-loader?minimize" },
|
|
||||||
{ loader: "postcss-loader" },
|
|
||||||
]
|
|
||||||
})
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.less$/,
|
|
||||||
use: ExtractTextPlugin.extract({
|
|
||||||
use: [
|
|
||||||
{ loader: "css-loader?minimize" },
|
|
||||||
{ loader: "postcss-loader" },
|
|
||||||
{ loader: "less-loader" }
|
|
||||||
]
|
|
||||||
})
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.(ico|eot|ttf|woff|woff2)$/,
|
|
||||||
loader: "url-loader",
|
|
||||||
options: {
|
|
||||||
limit: 10000
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ // First party images are saved as files to be cached
|
|
||||||
test: /\.(png|jpg|gif|svg)$/,
|
|
||||||
exclude: /node_modules/,
|
|
||||||
loader: "file-loader",
|
|
||||||
options: {
|
|
||||||
name: "images/[name].[ext]"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ // Third party images are inlined
|
|
||||||
test: /\.(png|jpg|gif|svg)$/,
|
|
||||||
exclude: /web\/static/,
|
|
||||||
loader: "url-loader",
|
|
||||||
options: {
|
|
||||||
limit: 10000
|
|
||||||
}
|
|
||||||
},
|
|
||||||
]
|
|
||||||
},
|
|
||||||
stats: {
|
|
||||||
children: false,
|
|
||||||
warningsFilter: /source-map/
|
|
||||||
}
|
|
||||||
},
|
|
||||||
webDev: {
|
|
||||||
target: "web",
|
|
||||||
entry: "./src/web/index.js",
|
|
||||||
output: {
|
|
||||||
filename: "scripts.js",
|
|
||||||
path: __dirname + "/build/dev"
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
new HtmlWebpackPlugin({
|
|
||||||
filename: "index.html",
|
|
||||||
template: "./src/web/html/index.html",
|
|
||||||
compileTime: compileTime,
|
|
||||||
version: pkg.version,
|
|
||||||
})
|
|
||||||
],
|
|
||||||
watch: true
|
|
||||||
},
|
|
||||||
webProd: {
|
|
||||||
target: "web",
|
target: "web",
|
||||||
entry: "./src/web/index.js",
|
entry: "./src/web/index.js",
|
||||||
output: {
|
output: {
|
||||||
|
@ -255,6 +152,7 @@ module.exports = function (grunt) {
|
||||||
path: __dirname + "/build/prod"
|
path: __dirname + "/build/prod"
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
|
new webpack.DefinePlugin(BUILD_CONSTANTS),
|
||||||
new webpack.optimize.UglifyJsPlugin({
|
new webpack.optimize.UglifyJsPlugin({
|
||||||
compress: {
|
compress: {
|
||||||
"screw_ie8": true,
|
"screw_ie8": true,
|
||||||
|
@ -310,6 +208,30 @@ module.exports = function (grunt) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"webpack-dev-server": {
|
||||||
|
options: {
|
||||||
|
webpack: webpackConfig,
|
||||||
|
stats: {
|
||||||
|
children: false,
|
||||||
|
warningsFilter: /source-map/
|
||||||
|
},
|
||||||
|
},
|
||||||
|
start: {
|
||||||
|
webpack: {
|
||||||
|
target: "web",
|
||||||
|
entry: "./src/web/index.js",
|
||||||
|
plugins: [
|
||||||
|
new webpack.DefinePlugin(BUILD_CONSTANTS),
|
||||||
|
new HtmlWebpackPlugin({
|
||||||
|
filename: "index.html",
|
||||||
|
template: "./src/web/html/index.html",
|
||||||
|
compileTime: compileTime,
|
||||||
|
version: pkg.version,
|
||||||
|
})
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
copy: {
|
copy: {
|
||||||
ghPages: {
|
ghPages: {
|
||||||
options: {
|
options: {
|
||||||
|
|
|
@ -60,7 +60,9 @@
|
||||||
"style-loader": "^0.15.0",
|
"style-loader": "^0.15.0",
|
||||||
"url-loader": "^0.5.8",
|
"url-loader": "^0.5.8",
|
||||||
"web-resource-inliner": "^4.1.0",
|
"web-resource-inliner": "^4.1.0",
|
||||||
"webpack": "^2.2.1"
|
"webpack": "^2.2.1",
|
||||||
|
"webpack-dev-server": "^2.5.0",
|
||||||
|
"worker-loader": "^0.8.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bootstrap": "^3.3.7",
|
"bootstrap": "^3.3.7",
|
||||||
|
@ -89,6 +91,7 @@
|
||||||
"zlibjs": "^0.2.0"
|
"zlibjs": "^0.2.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"start": "grunt dev",
|
||||||
"build": "grunt prod",
|
"build": "grunt prod",
|
||||||
"test": "grunt test",
|
"test": "grunt test",
|
||||||
"docs": "grunt docs"
|
"docs": "grunt docs"
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
<script type="application/javascript">
|
<script type="application/javascript">
|
||||||
// Load theme before the preloader is shown
|
// Load theme before the preloader is shown
|
||||||
document.querySelector(":root").className = JSON.parse(localStorage.getItem("options")).theme;
|
document.querySelector(":root").className = (JSON.parse(localStorage.getItem("options")) || {}).theme;
|
||||||
|
|
||||||
// Define loading messages
|
// Define loading messages
|
||||||
const loadingMsgs = [
|
const loadingMsgs = [
|
||||||
|
|
107
webpack.config.js
Normal file
107
webpack.config.js
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
const webpack = require("webpack");
|
||||||
|
const ExtractTextPlugin = require("extract-text-webpack-plugin");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Webpack configuration details for use with Grunt.
|
||||||
|
*
|
||||||
|
* @author n1474335 [n1474335@gmail.com]
|
||||||
|
* @copyright Crown Copyright 2017
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
const banner = "/**\n" +
|
||||||
|
"* CyberChef - The Cyber Swiss Army Knife\n" +
|
||||||
|
"*\n" +
|
||||||
|
"* @copyright Crown Copyright 2016\n" +
|
||||||
|
"* @license Apache-2.0\n" +
|
||||||
|
"*\n" +
|
||||||
|
"* Copyright 2016 Crown Copyright\n" +
|
||||||
|
"*\n" +
|
||||||
|
'* Licensed under the Apache License, Version 2.0 (the "License");\n' +
|
||||||
|
"* you may not use this file except in compliance with the License.\n" +
|
||||||
|
"* You may obtain a copy of the License at\n" +
|
||||||
|
"*\n" +
|
||||||
|
"* http://www.apache.org/licenses/LICENSE-2.0\n" +
|
||||||
|
"*\n" +
|
||||||
|
"* Unless required by applicable law or agreed to in writing, software\n" +
|
||||||
|
'* distributed under the License is distributed on an "AS IS" BASIS,\n' +
|
||||||
|
"* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" +
|
||||||
|
"* See the License for the specific language governing permissions and\n" +
|
||||||
|
"* limitations under the License.\n" +
|
||||||
|
"*/\n";
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
plugins: [
|
||||||
|
new webpack.ProvidePlugin({
|
||||||
|
$: "jquery",
|
||||||
|
jQuery: "jquery",
|
||||||
|
moment: "moment-timezone"
|
||||||
|
}),
|
||||||
|
new webpack.BannerPlugin({
|
||||||
|
banner: banner,
|
||||||
|
raw: true,
|
||||||
|
entryOnly: true
|
||||||
|
}),
|
||||||
|
new ExtractTextPlugin("styles.css"),
|
||||||
|
],
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
jquery: "jquery/src/jquery"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.js$/,
|
||||||
|
exclude: /node_modules/,
|
||||||
|
loader: "babel-loader?compact=false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.css$/,
|
||||||
|
use: ExtractTextPlugin.extract({
|
||||||
|
use: [
|
||||||
|
{ loader: "css-loader?minimize" },
|
||||||
|
{ loader: "postcss-loader" },
|
||||||
|
]
|
||||||
|
})
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.less$/,
|
||||||
|
use: ExtractTextPlugin.extract({
|
||||||
|
use: [
|
||||||
|
{ loader: "css-loader?minimize" },
|
||||||
|
{ loader: "postcss-loader" },
|
||||||
|
{ loader: "less-loader" }
|
||||||
|
]
|
||||||
|
})
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.(ico|eot|ttf|woff|woff2)$/,
|
||||||
|
loader: "url-loader",
|
||||||
|
options: {
|
||||||
|
limit: 10000
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ // First party images are saved as files to be cached
|
||||||
|
test: /\.(png|jpg|gif|svg)$/,
|
||||||
|
exclude: /node_modules/,
|
||||||
|
loader: "file-loader",
|
||||||
|
options: {
|
||||||
|
name: "images/[name].[ext]"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ // Third party images are inlined
|
||||||
|
test: /\.(png|jpg|gif|svg)$/,
|
||||||
|
exclude: /web\/static/,
|
||||||
|
loader: "url-loader",
|
||||||
|
options: {
|
||||||
|
limit: 10000
|
||||||
|
}
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
stats: {
|
||||||
|
children: false,
|
||||||
|
warningsFilter: /source-map/
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in a new issue