From 02481fe3f0b6b321dde07bf688007c4d9123a407 Mon Sep 17 00:00:00 2001 From: Becky Gilbert Date: Fri, 2 Feb 2024 12:02:21 -0800 Subject: [PATCH] fix build errors in GH actions by moving rollup-plugin-serve and watch into separate script (npm run dev) --- packages/lookit-initjspsych/package.json | 3 ++- .../lookit-initjspsych/rollup.config.dev.mjs | 26 +++++++++++++++++++ packages/lookit-initjspsych/rollup.config.mjs | 25 +----------------- 3 files changed, 29 insertions(+), 25 deletions(-) create mode 100644 packages/lookit-initjspsych/rollup.config.dev.mjs diff --git a/packages/lookit-initjspsych/package.json b/packages/lookit-initjspsych/package.json index 25152e6f..b72a7d8f 100644 --- a/packages/lookit-initjspsych/package.json +++ b/packages/lookit-initjspsych/package.json @@ -5,7 +5,8 @@ "main": "index.js", "scripts": { "test": "jest --coverage", - "build": "rollup --config --watch" + "build": "rollup --config", + "dev": "rollup --config rollup.config.dev.mjs --watch" }, "author": "", "license": "ISC", diff --git a/packages/lookit-initjspsych/rollup.config.dev.mjs b/packages/lookit-initjspsych/rollup.config.dev.mjs new file mode 100644 index 00000000..70dbcdde --- /dev/null +++ b/packages/lookit-initjspsych/rollup.config.dev.mjs @@ -0,0 +1,26 @@ +import { makeRollupConfig } from "@jspsych/config/rollup"; +import serve from 'rollup-plugin-serve'; + +let rollupConfig = makeRollupConfig("lookitInitJsPsych"); + +const host = 'localhost'; +const port = 10001; // this needs to change for each package +const content_dir = 'dist/'; + +rollupConfig.plugins = [ + // options: https://github.com/thgh/rollup-plugin-serve/tree/master?tab=readme-ov-file#options + serve({ + contentBase: content_dir, + historyApiFallback: true, + host: host, + port: port, + onListening: function (server) { + const address = server.address(); + const host = (address.address === '::' || address.address === '::1') ? 'localhost' : address.address; + const protocol = this.https ? 'https' : 'http'; + console.log(`Server listening at ${protocol}://${host}:${address.port}/`); + } + }) +]; + +export default rollupConfig; diff --git a/packages/lookit-initjspsych/rollup.config.mjs b/packages/lookit-initjspsych/rollup.config.mjs index 70dbcdde..2cdba26d 100644 --- a/packages/lookit-initjspsych/rollup.config.mjs +++ b/packages/lookit-initjspsych/rollup.config.mjs @@ -1,26 +1,3 @@ import { makeRollupConfig } from "@jspsych/config/rollup"; -import serve from 'rollup-plugin-serve'; -let rollupConfig = makeRollupConfig("lookitInitJsPsych"); - -const host = 'localhost'; -const port = 10001; // this needs to change for each package -const content_dir = 'dist/'; - -rollupConfig.plugins = [ - // options: https://github.com/thgh/rollup-plugin-serve/tree/master?tab=readme-ov-file#options - serve({ - contentBase: content_dir, - historyApiFallback: true, - host: host, - port: port, - onListening: function (server) { - const address = server.address(); - const host = (address.address === '::' || address.address === '::1') ? 'localhost' : address.address; - const protocol = this.https ? 'https' : 'http'; - console.log(`Server listening at ${protocol}://${host}:${address.port}/`); - } - }) -]; - -export default rollupConfig; +export default makeRollupConfig("lookitInitJsPsych");