From 9f776e159b343697a5fb85bc2b9d6914b689bce3 Mon Sep 17 00:00:00 2001 From: "[1000i100] Millicent Billette" <git@1000i100.fr> Date: Wed, 12 Sep 2018 14:29:09 +0200 Subject: [PATCH] FIX: extend compatibility by removing module mention in prod --- .gitlab-ci.yml | 1 + build.js | 6 +----- package.json | 1 + prod.js | 16 ++++++++++++++++ public/index.html | 3 +-- 5 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 prod.js diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 77f0bd5..2130a7b 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 3eed99b..ab4eedc 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 f528a25..a79d2b6 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 0000000..8380419 --- /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 6cb8c30..7f9cacd 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> -- GitLab