From: Jérôme Benoit Date: Sat, 27 May 2023 20:44:22 +0000 (+0200) Subject: refactor: only copy assets used at runtime in the bundle X-Git-Tag: v1.2.15~27 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=672551edc7fdd48814717269e2f814bd54fa387b;p=e-mobility-charging-stations-simulator.git refactor: only copy assets used at runtime in the bundle Signed-off-by: Jérôme Benoit --- diff --git a/package.json b/package.json index 14fdfbb4..55544a29 100644 --- a/package.json +++ b/package.json @@ -130,6 +130,7 @@ "@types/ws": "^8.5.4", "@typescript-eslint/eslint-plugin": "^5.59.7", "@typescript-eslint/parser": "^5.59.7", + "@web/rollup-plugin-copy": "^0.4.0", "auto-changelog": "^2.4.0", "c8": "^7.13.0", "clinic": "^12.1.0", @@ -153,7 +154,6 @@ "robohydra": "^0.6.9", "rollup": "^3.23.0", "rollup-plugin-analyzer": "^4.0.0", - "rollup-plugin-copy": "^3.4.0", "rollup-plugin-delete": "^2.0.0", "semver": "^7.5.1", "sinon": "^15.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3185c5cf..444952a0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -128,6 +128,9 @@ devDependencies: '@typescript-eslint/parser': specifier: ^5.59.7 version: 5.59.7(eslint@8.41.0)(typescript@5.0.4) + '@web/rollup-plugin-copy': + specifier: ^0.4.0 + version: 0.4.0 auto-changelog: specifier: ^2.4.0 version: 2.4.0 @@ -197,9 +200,6 @@ devDependencies: rollup-plugin-analyzer: specifier: ^4.0.0 version: 4.0.0 - rollup-plugin-copy: - specifier: ^3.4.0 - version: 3.4.0 rollup-plugin-delete: specifier: ^2.0.0 version: 2.0.0 @@ -1420,12 +1420,6 @@ packages: resolution: {integrity: sha512-LG4opVs2ANWZ1TJoKc937iMmNstM/d0ae1vNbnBvBhqCSezgVUOzcLCqbI5elV8Vy6WKwKjaqR+zO9VKirBBCA==} dev: true - /@types/fs-extra@8.1.2: - resolution: {integrity: sha512-SvSrYXfWSc7R4eqnOzbQF4TZmfpNSM9FrSWLU3EUnWBuyZqNBOrv1B1JA3byUDPUl9z4Ab3jeZG2eDdySlgNMg==} - dependencies: - '@types/node': 20.2.5 - dev: true - /@types/geojson@7946.0.10: resolution: {integrity: sha512-Nmh0K3iWQJzniTuPRcJn5hxXkfB1T1pgB89SBig5PlJQU5yocazeu4jATJlaA0GYFKWMqDdvYemoSnF2pXgLVA==} @@ -1694,6 +1688,13 @@ packages: eslint-visitor-keys: 3.4.1 dev: true + /@web/rollup-plugin-copy@0.4.0: + resolution: {integrity: sha512-CSSx4j+WR0UNgT8GX8OTkLGOxWsCOxRDYHVo0WFqOwCnAeLtWJNQI0YamBEk9ozYSm9AW1YxKUBA79Rf+05tLQ==} + engines: {node: '>=16.0.0'} + dependencies: + glob: 7.2.3 + dev: true + /@webgpu/types@0.1.16: resolution: {integrity: sha512-9E61voMP4+Rze02jlTXud++Htpjyyk8vw5Hyw9FGRrmhHQg2GqbuOfwf5Klrb8vTxc2XWI3EfO7RUHMpxTj26A==} dev: true @@ -2839,10 +2840,6 @@ packages: color-string: 1.9.1 dev: false - /colorette@1.4.0: - resolution: {integrity: sha512-Y2oEozpomLn7Q3HFP7dpww7AtMJplbM9lGZP6RDfHqmbeRjiwRg4n6VM6j4KLmRke85uWEI7JqF17f3pqdRA0g==} - dev: true - /colorette@2.0.19: resolution: {integrity: sha512-3tlv/dIP7FWvj3BsbHrGLJ6l/oKh1O3TcgBqMn+yyCagOxc23fyzDS6HypQbgxWbkpDnf52p1LuR4eWDQ/K9WQ==} @@ -4800,20 +4797,6 @@ packages: define-properties: 1.2.0 dev: true - /globby@10.0.1: - resolution: {integrity: sha512-sSs4inE1FB2YQiymcmTv6NWENryABjUNPeWhOvmn4SjtKybglsyPZxFB3U1/+L1bYi0rNZDqCLlHyLYDl1Pq5A==} - engines: {node: '>=8'} - dependencies: - '@types/glob': 7.2.0 - array-union: 2.1.0 - dir-glob: 3.0.1 - fast-glob: 3.2.12 - glob: 7.2.3 - ignore: 5.2.4 - merge2: 1.4.1 - slash: 3.0.0 - dev: true - /globby@10.0.2: resolution: {integrity: sha512-7dUi7RvCoT/xast/o/dLN53oqND4yk0nsHkhRgn9w65C4PofCLOoJ39iSOg+qVDdWQPIEj+eszMHQ+aLVwwQSg==} engines: {node: '>=8'} @@ -5589,11 +5572,6 @@ packages: engines: {node: '>=8'} dev: true - /is-plain-object@3.0.1: - resolution: {integrity: sha512-Xnpx182SBMrr/aBik8y+GuR4U1L9FqMSojwDQwPMmxyC6bvEqly9UBCxhauBF5vNh2gwWJNX6oDV7O+OM4z34g==} - engines: {node: '>=0.10.0'} - dev: true - /is-plain-object@5.0.0: resolution: {integrity: sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==} engines: {node: '>=0.10.0'} @@ -8298,17 +8276,6 @@ packages: engines: {node: '>=8.0.0'} dev: true - /rollup-plugin-copy@3.4.0: - resolution: {integrity: sha512-rGUmYYsYsceRJRqLVlE9FivJMxJ7X6jDlP79fmFkL8sJs7VVMSVyA2yfyL+PGyO/vJs4A87hwhgVfz61njI+uQ==} - engines: {node: '>=8.3'} - dependencies: - '@types/fs-extra': 8.1.2 - colorette: 1.4.0 - fs-extra: 8.1.0 - globby: 10.0.1 - is-plain-object: 3.0.1 - dev: true - /rollup-plugin-delete@2.0.0: resolution: {integrity: sha512-/VpLMtDy+8wwRlDANuYmDa9ss/knGsAgrDhM+tEwB1npHwNu4DYNmDfUL55csse/GHs9Q+SMT/rw9uiaZ3pnzA==} engines: {node: '>=10'} diff --git a/rollup.config.mjs b/rollup.config.mjs index e78c1e9e..e6602426 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -2,8 +2,8 @@ import json from '@rollup/plugin-json'; import terser from '@rollup/plugin-terser'; import typescript from '@rollup/plugin-typescript'; +import { copy } from '@web/rollup-plugin-copy'; import analyze from 'rollup-plugin-analyzer'; -import copy from 'rollup-plugin-copy'; import del from 'rollup-plugin-delete'; const isDevelopmentBuild = process.env.BUILD === 'development'; @@ -68,7 +68,14 @@ export default { ], }), copy({ - targets: [{ src: 'src/assets', dest: 'dist/' }], + rootDir: 'src', + patterns: 'assets/**/*.json', + exclude: [ + 'assets/config-template.json', + 'assets/*config[-_]*.json', + 'assets/idtags-template.json', + 'assets/ui-protocol/**/*', + ], }), isAnalyzeBuild && analyze(), ],