-
Notifications
You must be signed in to change notification settings - Fork 946
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[integration] Fix tests and standalone build
- Loading branch information
Samuel Hassine
committed
Mar 4, 2022
1 parent
1e1e4e3
commit 13b3295
Showing
4 changed files
with
74 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
opencti-platform/opencti-front/builder/prod/prod-keepfiles.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
const esbuild = require("esbuild"); | ||
const { RelayPlugin } = require("../plugin/esbuild-relay"); | ||
const fsExtra = require("fs-extra"); | ||
const fs = require("fs"); | ||
|
||
const buildPath = "./builder/prod/build/"; | ||
esbuild | ||
.build({ | ||
logLevel: "info", | ||
plugins: [RelayPlugin], | ||
entryPoints: ["src/index.tsx"], | ||
bundle: true, | ||
loader: { | ||
".js": "jsx", | ||
".svg": "file", | ||
".png": "file", | ||
".woff": "dataurl", | ||
".woff2": "dataurl", | ||
".ttf": "dataurl", | ||
".eot": "dataurl", | ||
}, | ||
assetNames: "static/media/[name]-[hash]", | ||
entryNames: "static/[ext]/opencti-[hash]", | ||
target: ["chrome58"], | ||
minify: true, | ||
keepNames: false, | ||
sourcemap: false, | ||
sourceRoot: "src", | ||
sourcesContent: false, | ||
outdir: "builder/prod/build", | ||
incremental: false, | ||
}) | ||
.then(() => { | ||
// Copy file | ||
fsExtra.copySync("./builder/public/", buildPath, { | ||
recursive: true, | ||
overwrite: true, | ||
}); | ||
// Generate index.html | ||
const cssStaticFiles = fs.readdirSync(buildPath + "static/css"); | ||
const cssLinks = cssStaticFiles.map( | ||
(f) => `<link href="%BASE_PATH%/static/css/${f}" rel="stylesheet">` | ||
); | ||
const cssImport = cssLinks.join("\n"); | ||
const jsStaticFiles = fs.readdirSync(buildPath + "static/js"); | ||
const jsLinks = jsStaticFiles.map( | ||
(f) => `<script defer="defer" src="%BASE_PATH%/static/js/${f}"></script>` | ||
); | ||
const jsImport = jsLinks.join("\n"); | ||
const indexHtml = ` | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"/> | ||
<link rel="shortcut icon" href="%BASE_PATH%/static/favicon.png"> | ||
<script>window.BASE_PATH = "%BASE_PATH%"</script> | ||
<meta name="viewport" content="width=device-width,initial-scale=1"> | ||
<title>OpenCTI - Cyber Threat Intelligence Platform</title> | ||
${jsImport} | ||
${cssImport} | ||
</head> | ||
<body> | ||
<noscript>You need to enable JavaScript to run this app.</noscript> | ||
<div id="root"></div> | ||
</body> | ||
</html>`; | ||
fs.writeFileSync(buildPath + "index.html", indexHtml); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters