refactor: only copy assets used at runtime in the bundle
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 27 May 2023 20:44:22 +0000 (22:44 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 27 May 2023 20:44:22 +0000 (22:44 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
package.json
pnpm-lock.yaml
rollup.config.mjs

index 14fdfbb4a0c57f5369527b0b2afe6321ee021f9d..55544a29687c88b8a160756f2bc1b859c8b12229 100644 (file)
     "@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",
     "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",
index 3185c5cfbb1e49df3e8f06dadaacb42cb2a07f65..444952a03ffdedfa3e4e4ecbae063f70318ac717 100644 (file)
@@ -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'}
index e78c1e9e26e145eaffa217fb2b0813520e9cf6c4..e660242612b1a9892dd84a0daa390819f3356dda 100644 (file)
@@ -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(),
   ],