From 2f8f46910942b33a2703eeabf00c2df2c9a5c1fc Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Fri, 11 Jun 2021 18:10:39 +0200 Subject: [PATCH] build: make es6 build work for windows --- package.json | 3 ++- tools/remove-woff.js | 24 ++++++++++++++++++++++++ yarn.lock | 14 +++++++++++++- 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 tools/remove-woff.js diff --git a/package.json b/package.json index 374d1e905..69983de3d 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "start": "yarn electron:build && cross-env NODE_ENV=DEV electron .", "startFrontend": "ng serve", "serveProd": "ng serve --prod", - "removeWOFF1": "find dist/ -type f -iname '*.woff' -delete && find dist/ -type f -iname '*.css' -exec sed -i \"s/, url\\('.*'\\) format\\('woff'\\)//g\" {} \\;", + "removeWOFF1": "node ./tools/remove-woff.js", "buildFrontend:prod:es6": "cross-env BROWSERSLIST_ENV='modern' ng build --prod && yarn removeWOFF1", "buildFrontend:prodWeb": "ng build --prod --configuration productionWeb", "buildFrontend:stage:es6": "cross-env BROWSERSLIST_ENV='modern' ng build --prod --configuration stage && yarn removeWOFF1", @@ -180,6 +180,7 @@ "eslint-plugin-prettier": "^3.4.0", "eslint-plugin-unused-imports": "^1.1.1", "file-saver": "^2.0.2", + "glob": "^7.1.7", "hammerjs": "^2.0.8", "helpful-decorators": "^2.1.0", "husky": "^4.2.5", diff --git a/tools/remove-woff.js b/tools/remove-woff.js new file mode 100644 index 000000000..f13b469ea --- /dev/null +++ b/tools/remove-woff.js @@ -0,0 +1,24 @@ +/* eslint-env es6 */ +const glob = require('glob'); +const fs = require('fs'); + +// "removeWOFF2": "find dist/ -type f -iname '*.woff' -delete && find dist/ -type f -iname '*.css' -exec sed -i \"s/, url\\('.*'\\) format\\('woff'\\)//g\" {} \\;", + +glob('dist/*.woff', function (er, files) { + files.forEach((filePath) => { + fs.unlinkSync(filePath); + }); +}); + +// NOTE: this would remove the dead references, but it should be no problem anyway +// glob('dist/*.css', function (er, files) { +// files.forEach((filePath) => { +// const fileContent = fs.readFileSync(filePath, { encoding: 'utf8' }); +// const newFileContent = fileContent +// .replace(/,url\(.*\) format\('woff'\)/g, '') +// .replace(/,url\(.*\) format\("woff"\)/g, '') +// .replace(/url\(.*\) format\('woff'\)/g, '') +// .replace(/url\(.*\) format\("woff"\)/g, ''); +// fs.writeFileSync(filePath, newFileContent); +// }); +// }); diff --git a/yarn.lock b/yarn.lock index d0c04ed2d..9139421f3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3236,7 +3236,7 @@ cdav-library@nextcloud/cdav-library: version "0.0.1" resolved "https://codeload.github.com/nextcloud/cdav-library/tar.gz/7fdc09ccc4917635c5189a878be9a899ee81f799" dependencies: - core-js "^3.13.0" + core-js "^3.10.0" regenerator-runtime "^0.13.7" chai-nightwatch@^0.4.0: @@ -6301,6 +6301,18 @@ glob@7.1.6, glob@^7.0.0, glob@^7.0.3, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6: once "^1.3.0" path-is-absolute "^1.0.0" +glob@^7.1.7: + version "7.1.7" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.7.tgz#3b193e9233f01d42d0b3f78294bbeeb418f94a90" + integrity sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + global-agent@^2.0.2: version "2.1.12" resolved "https://registry.yarnpkg.com/global-agent/-/global-agent-2.1.12.tgz#e4ae3812b731a9e81cbf825f9377ef450a8e4195"