diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 77f0bd5f23c69ae7446c2c016c06169a85952501..2130a7bd390e0a713ce010cc9beb14e9be7a4905 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,6 +9,7 @@ build-and-clean: - npm install - npm run postinstall - npm run build + - npm run prod artifacts: untracked: true paths: diff --git a/build.js b/build.js index 3eed99b8997d198b97fe698e3a0f883a008c414e..ab4eedc60b04d2682f637fa8c09d6fccc5258d9a 100644 --- a/build.js +++ b/build.js @@ -7,8 +7,4 @@ try{fs.writeFileSync("public/vendors/nacl.js",(fs.readFileSync("public/vendors/n .replace("(function(nacl) {","var nacl = {};") .replace("})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));","export {nacl};") ,"utf8");} catch (e) {console.error(e);} -// let js = fs.readFileSync("node_modules/jparticles/production/jparticles.js","utf8"); -// js += fs.readFileSync("node_modules/jparticles/production/particle.js","utf8"); -// js += fs.readFileSync("main.js","utf8"); -// fs.writeFileSync("main.js",js,"utf8"); -// fs.writeFileSync("index.html",(fs.readFileSync("index.html","utf8")).replace(/(.*node_modules.*)/g,''),"utf8"); + diff --git a/package.json b/package.json index f528a253a5ecdd14c4c1400d55bb5aae6f27cf84..a79d2b6248b57a504c8cbd575a5a665d46f30ef1 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "scripts": { "postinstall": "node build.js", "build": "rollup public/worker.js --format iife --file public/generated.worker.js && rollup public/main.js --format iife --file public/generated.main.js", + "prod": "node prod.js", "test": "echo open public/test.html in your browser" }, "repository": { diff --git a/prod.js b/prod.js new file mode 100644 index 0000000000000000000000000000000000000000..8380419d35f44f68adbd04deccf1bab89c2800a4 --- /dev/null +++ b/prod.js @@ -0,0 +1,16 @@ +const fs = require("fs"); +change( + `<script type="module" src="main.js"></script>`, + `<script src="generated.main.js"></script>`, + `public/index.html`); +change( + `Worker('generated.worker.js',{type:"module"})`, + `Worker('generated.worker.js')`, + `public/generated.main.js`); + +function change(thisString,withThisString,inThisFile) { + try{fs.writeFileSync(inThisFile,(fs.readFileSync(inThisFile,"utf8")) + .replace(thisString,withThisString) + ,"utf8");} catch (e) {console.error(e);} + +} diff --git a/public/index.html b/public/index.html index 6cb8c3023ecaf08ec753a312fe11c0c5909278a2..7f9cacd3867219addea18693b64b1750d9736cd5 100644 --- a/public/index.html +++ b/public/index.html @@ -97,7 +97,6 @@ space::[ _-.]{0,1} </style> </a> </footer> -<!--<script type="module" src="main.js"></script>--> -<script src="generated.main.js"></script> +<script type="module" src="main.js"></script> </body> </html>