mirror of
https://github.com/gchq/CyberChef
synced 2024-11-15 00:57:08 +00:00
Fixed module detection issue. Closes #881
This commit is contained in:
parent
fd5b6c5243
commit
f7acef4642
1 changed files with 68 additions and 46 deletions
114
Gruntfile.js
114
Gruntfile.js
|
@ -26,7 +26,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", "clean:config", "exec:generateConfig", "webpack:web",
|
"eslint", "clean:prod", "clean:config", "exec:generateConfig", "findModules", "webpack:web",
|
||||||
"copy:standalone", "zip:standalone", "clean:standalone", "chmod"
|
"copy:standalone", "zip:standalone", "clean:standalone", "chmod"
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -58,6 +58,19 @@ module.exports = function (grunt) {
|
||||||
grunt.registerTask("tests", "test");
|
grunt.registerTask("tests", "test");
|
||||||
grunt.registerTask("lint", "eslint");
|
grunt.registerTask("lint", "eslint");
|
||||||
|
|
||||||
|
grunt.registerTask("findModules",
|
||||||
|
"Finds all generated modules and updates the entry point list for Webpack",
|
||||||
|
function(arg1, arg2) {
|
||||||
|
const moduleEntryPoints = listEntryModules();
|
||||||
|
|
||||||
|
grunt.log.writeln(`Found ${Object.keys(moduleEntryPoints).length} modules.`);
|
||||||
|
|
||||||
|
grunt.config.set("webpack.web.entry",
|
||||||
|
Object.assign({
|
||||||
|
main: "./src/web/index.js"
|
||||||
|
}, moduleEntryPoints));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// Load tasks provided by each plugin
|
// Load tasks provided by each plugin
|
||||||
grunt.loadNpmTasks("grunt-eslint");
|
grunt.loadNpmTasks("grunt-eslint");
|
||||||
|
@ -83,7 +96,53 @@ module.exports = function (grunt) {
|
||||||
PKG_VERSION: JSON.stringify(pkg.version),
|
PKG_VERSION: JSON.stringify(pkg.version),
|
||||||
},
|
},
|
||||||
moduleEntryPoints = listEntryModules(),
|
moduleEntryPoints = listEntryModules(),
|
||||||
nodeConsumerTestPath = "~/tmp-cyberchef";
|
nodeConsumerTestPath = "~/tmp-cyberchef",
|
||||||
|
/**
|
||||||
|
* Configuration for Webpack production build. Defined as a function so that it
|
||||||
|
* can be recalculated when new modules are generated.
|
||||||
|
*/
|
||||||
|
webpackProdConf = () => {
|
||||||
|
return {
|
||||||
|
mode: "production",
|
||||||
|
target: "web",
|
||||||
|
entry: Object.assign({
|
||||||
|
main: "./src/web/index.js"
|
||||||
|
}, moduleEntryPoints),
|
||||||
|
output: {
|
||||||
|
path: __dirname + "/build/prod",
|
||||||
|
filename: chunkData => {
|
||||||
|
return chunkData.chunk.name === "main" ? "assets/[name].js": "[name].js";
|
||||||
|
},
|
||||||
|
globalObject: "this"
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
"./config/modules/OpModules.mjs": "./config/modules/Default.mjs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new webpack.DefinePlugin(BUILD_CONSTANTS),
|
||||||
|
new HtmlWebpackPlugin({
|
||||||
|
filename: "index.html",
|
||||||
|
template: "./src/web/html/index.html",
|
||||||
|
chunks: ["main"],
|
||||||
|
compileTime: compileTime,
|
||||||
|
version: pkg.version,
|
||||||
|
minify: {
|
||||||
|
removeComments: true,
|
||||||
|
collapseWhitespace: true,
|
||||||
|
minifyJS: true,
|
||||||
|
minifyCSS: true
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
new BundleAnalyzerPlugin({
|
||||||
|
analyzerMode: "static",
|
||||||
|
reportFilename: "BundleAnalyzerReport.html",
|
||||||
|
openAnalyzer: false
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -154,48 +213,7 @@ module.exports = function (grunt) {
|
||||||
},
|
},
|
||||||
webpack: {
|
webpack: {
|
||||||
options: webpackConfig,
|
options: webpackConfig,
|
||||||
web: () => {
|
web: webpackProdConf(),
|
||||||
return {
|
|
||||||
mode: "production",
|
|
||||||
target: "web",
|
|
||||||
entry: Object.assign({
|
|
||||||
main: "./src/web/index.js"
|
|
||||||
}, moduleEntryPoints),
|
|
||||||
output: {
|
|
||||||
path: __dirname + "/build/prod",
|
|
||||||
filename: chunkData => {
|
|
||||||
return chunkData.chunk.name === "main" ? "assets/[name].js": "[name].js";
|
|
||||||
},
|
|
||||||
globalObject: "this"
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
alias: {
|
|
||||||
"./config/modules/OpModules.mjs": "./config/modules/Default.mjs"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
new webpack.DefinePlugin(BUILD_CONSTANTS),
|
|
||||||
new HtmlWebpackPlugin({
|
|
||||||
filename: "index.html",
|
|
||||||
template: "./src/web/html/index.html",
|
|
||||||
chunks: ["main"],
|
|
||||||
compileTime: compileTime,
|
|
||||||
version: pkg.version,
|
|
||||||
minify: {
|
|
||||||
removeComments: true,
|
|
||||||
collapseWhitespace: true,
|
|
||||||
minifyJS: true,
|
|
||||||
minifyCSS: true
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
new BundleAnalyzerPlugin({
|
|
||||||
analyzerMode: "static",
|
|
||||||
reportFilename: "BundleAnalyzerReport.html",
|
|
||||||
openAnalyzer: false
|
|
||||||
}),
|
|
||||||
]
|
|
||||||
};
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
"webpack-dev-server": {
|
"webpack-dev-server": {
|
||||||
options: {
|
options: {
|
||||||
|
@ -345,7 +363,8 @@ module.exports = function (grunt) {
|
||||||
command: "git gc --prune=now --aggressive"
|
command: "git gc --prune=now --aggressive"
|
||||||
},
|
},
|
||||||
sitemap: {
|
sitemap: {
|
||||||
command: "node --experimental-modules --no-warnings --no-deprecation src/web/static/sitemap.mjs > build/prod/sitemap.xml"
|
command: "node --experimental-modules --no-warnings --no-deprecation src/web/static/sitemap.mjs > build/prod/sitemap.xml",
|
||||||
|
sync: true
|
||||||
},
|
},
|
||||||
generateConfig: {
|
generateConfig: {
|
||||||
command: chainCommands([
|
command: chainCommands([
|
||||||
|
@ -354,7 +373,8 @@ module.exports = function (grunt) {
|
||||||
"node --experimental-modules --no-warnings --no-deprecation src/core/config/scripts/generateOpsIndex.mjs",
|
"node --experimental-modules --no-warnings --no-deprecation src/core/config/scripts/generateOpsIndex.mjs",
|
||||||
"node --experimental-modules --no-warnings --no-deprecation src/core/config/scripts/generateConfig.mjs",
|
"node --experimental-modules --no-warnings --no-deprecation src/core/config/scripts/generateConfig.mjs",
|
||||||
"echo '--- Config scripts finished. ---\n'"
|
"echo '--- Config scripts finished. ---\n'"
|
||||||
])
|
]),
|
||||||
|
sync: true
|
||||||
},
|
},
|
||||||
generateNodeIndex: {
|
generateNodeIndex: {
|
||||||
command: chainCommands([
|
command: chainCommands([
|
||||||
|
@ -362,6 +382,7 @@ module.exports = function (grunt) {
|
||||||
"node --experimental-modules --no-warnings --no-deprecation src/node/config/scripts/generateNodeIndex.mjs",
|
"node --experimental-modules --no-warnings --no-deprecation src/node/config/scripts/generateNodeIndex.mjs",
|
||||||
"echo '--- Node index generated. ---\n'"
|
"echo '--- Node index generated. ---\n'"
|
||||||
]),
|
]),
|
||||||
|
sync: true
|
||||||
},
|
},
|
||||||
opTests: {
|
opTests: {
|
||||||
command: "node --experimental-modules --no-warnings --no-deprecation tests/operations/index.mjs"
|
command: "node --experimental-modules --no-warnings --no-deprecation tests/operations/index.mjs"
|
||||||
|
@ -381,6 +402,7 @@ module.exports = function (grunt) {
|
||||||
`cd ${nodeConsumerTestPath}`,
|
`cd ${nodeConsumerTestPath}`,
|
||||||
"npm link cyberchef"
|
"npm link cyberchef"
|
||||||
]),
|
]),
|
||||||
|
sync: true
|
||||||
},
|
},
|
||||||
teardownNodeConsumers: {
|
teardownNodeConsumers: {
|
||||||
command: chainCommands([
|
command: chainCommands([
|
||||||
|
|
Loading…
Reference in a new issue