From 0354fb3da01f23df3440effafb4f15a93457fecc Mon Sep 17 00:00:00 2001 From: kpal Date: Mon, 11 Mar 2024 11:10:34 +0000 Subject: [PATCH 1/2] changed rollup to only rebuild standalone files not entire metadata --- examples/rollup.config.js | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/examples/rollup.config.js b/examples/rollup.config.js index defb8e7460a..c3de564a1a6 100644 --- a/examples/rollup.config.js +++ b/examples/rollup.config.js @@ -1,4 +1,3 @@ -import date from 'date-and-time'; import * as fs from 'node:fs'; import fse from 'fs-extra'; import { fileURLToPath } from 'node:url'; @@ -89,13 +88,27 @@ function getEnginePathFiles() { } /** + * @param {string} name - The timer name. * @returns {RollupPlugin} The plugin. */ -function timestamp() { +function timeStart(name) { return { - name: 'timestamp', + name: 'time-start', + buildStart() { + console.time(name); + } + }; +} + +/** + * @param {string} name - The timer name. + * @returns {RollupPlugin} The plugin. + */ +function timeEnd(name) { + return { + name: 'time-end', writeBundle() { - console.log("\x1b[32m", "Finished at: " + date.format(new Date(), 'HH:mm:ss')); + console.timeEnd(name); } }; } @@ -168,9 +181,9 @@ function buildAndWatchStandaloneExamples() { } }, generateBundle() { - const cmd = `cross-env NODE_ENV=${NODE_ENV} ENGINE_PATH=${ENGINE_PATH} npm run build:pre`; - console.log(cmd); - execSync(cmd, { stdio: 'inherit' }); + const cmd = `cross-env NODE_ENV=${NODE_ENV} ENGINE_PATH=${ENGINE_PATH} npm run build:standalone`; + console.log("\x1b[32m%s\x1b[0m", cmd); + execSync(cmd); } }; } @@ -180,6 +193,9 @@ function getEngineTargets() { // Outputs: dist/iframe/playcanvas-extras.mjs scriptTargetEs6('pcx', '../extras/index.js', 'dist/iframe/playcanvas-extras.mjs') ]; + if (ENGINE_PATH) { + return targets; + } if (NODE_ENV === 'production') { // Outputs: dist/iframe/playcanvas.mjs targets.push(buildTarget('release', 'es6', '../src/index.js', 'dist/iframe')); @@ -202,9 +218,10 @@ export default [ file: `dist/copy.tmp` }, plugins: [ + timeStart('examples'), buildAndWatchStandaloneExamples(), copyStaticFiles(STATIC_FILES), - timestamp() + timeEnd('examples') ] }, { @@ -215,6 +232,7 @@ export default [ format: 'umd' }, plugins: [ + timeStart('site'), alias({ entries: { // define supported module overrides @@ -231,7 +249,7 @@ export default [ preventAssignment: true }), (NODE_ENV === 'production' && terser()), - timestamp() + timeEnd('site') ] }, ...getEngineTargets() From 1cebd086c2d15006d6920d60bd866669eb23d77c Mon Sep 17 00:00:00 2001 From: kpal Date: Mon, 11 Mar 2024 12:20:50 +0000 Subject: [PATCH 2/2] removed old watch commands; added prebuild before watch and build commands --- examples/package.json | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/examples/package.json b/examples/package.json index fa3d8ba75d6..5dba3503516 100644 --- a/examples/package.json +++ b/examples/package.json @@ -5,20 +5,17 @@ "main": "index.js", "type": "module", "scripts": { - "build": "cross-env NODE_ENV=production rollup -c", - "build:pre": "npm run -s build:metadata && npm run -s build:standalone && npm run -s build:sharing", + "build": "npm run -s build:pre && cross-env NODE_ENV=production rollup -c", + "build:pre": "npm run -s build:metadata && npm run -s build:sharing", "build:metadata": "node ./scripts/metadata.mjs", "build:sharing": "node ./scripts/sharing-html.mjs", "build:standalone": "node ./scripts/standalone-html.mjs", "build:thumbnails": "node ./scripts/thumbnails.mjs", - "rollup:watch": "cross-env NODE_ENV=development rollup -c -w", - "serve": "serve dist -l 5000 --no-request-logging --config ../serve.json", - "lint": "eslint . --ext .js,.ts,.tsx", - "watch": "cross-env concurrently --kill-others \"npm run rollup:watch\"", - "watch:debug": "cross-env ENGINE_PATH=../build/playcanvas.dbg.js npm run watch", - "watch:profiler": "cross-env ENGINE_PATH=../build/playcanvas.prf.js npm run watch", + "clean": "node ./scripts/clean.mjs", "develop": "cross-env NODE_ENV=development concurrently --kill-others \"npm run watch\" \"npm run serve\"", - "clean": "node ./scripts/clean.mjs" + "lint": "eslint . --ext .js,.ts,.tsx", + "serve": "serve dist -l 5000 --no-request-logging --config ../serve.json", + "watch": "npm run -s build:pre && cross-env NODE_ENV=development rollup -c -w" }, "eslintConfig": { "root": true,