-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to add webgazer into the experiments? #55
Comments
I found a way to load webgazer.js using html-webpack-plugin. Modified the build.config.mjs to add the script and recreate the html. import HtmlWebpackPlugin from 'html-webpack-plugin';
/** @param {import("webpack").Configuration} config */
export function webpack(config) {
// Find the HtmlWebpackPlugin instance in the plugins array
const htmlWebpackPluginIndex = config.plugins.findIndex(
plugin => plugin instanceof HtmlWebpackPlugin
);
if (htmlWebpackPluginIndex !== -1) {
// Modify the HtmlWebpackPlugin options to include webgazer.js
const originalOptions = config.plugins[htmlWebpackPluginIndex].userOptions;
config.plugins[htmlWebpackPluginIndex] = new HtmlWebpackPlugin({
...originalOptions,
scriptLoading: 'blocking',
templateContent: ({ htmlWebpackPlugin }) => `<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>first-experiment (Development Build)</title>
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.jsdelivr.net/gh/jspsych/jspsych@[email protected]/examples/js/webgazer/webgazer.js"></script>
<script defer src="js/app.js"></script>
<link href="css/main.css" rel="stylesheet">
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html>`});
}
return config;
} However, in future if jspsych-builder would add/change anything from the default html template, this may not work. Is there a better way to get this working? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I do not have experience with webpack that much. Can you please point out on how I can add additional javascript extensions in the
experiment.ts
file?Here is what I tried inside the
run
function:But I get the following error while running:
How can I load webgazer.js before calling
initJsPsych()
?The text was updated successfully, but these errors were encountered: