bjoluc / jspsych-builder

A CLI utility to easily develop and package jsPsych experiments
MIT License
46 stars 12 forks source link

Asset paths might be broken in builds #34

Closed robfuscator closed 2 years ago

robfuscator commented 2 years ago

Hey!

jspsych-builder version: 4.3.0

I don't want to completely rule out the possibility that I have messed something up on my side, but I think I have discovered a bug. :lady_beetle:

I'm using the new @assets pragma to include images in my experiment:

/*
 * @assets media/images
 */

While I'm developing using the integrated webpack-dev-server, everything works fine. But when I export the experiment to either a zip to run directly in the browser or a jzip to import it to JATOS, the "compiled" asset paths seem to be broken. In both environments, the images are not displayed, but instead a symbol is signifying that they could not be found:

image

I'm not sure what might me causing this. The repo where this occurs is the following:

Edit: I accidentally sent the issue too early :facepalm:

bjoluc commented 2 years ago

Hi @robfuscator,

thanks for providing the repo, very helpful! Luckily, this is jspsych-builder-unrelated: You should replace ../media/images/example-stimulus.jpg with media/images/example-stimulus.jpg. When loading the experiment via localhost, the browser resolves ../ to ./ because index.html is already hosted at the topmost directory level. When using the build zip or JATOS, however, ../ moves one directory level up in the URL, where the files do not exist.

Cheers!

robfuscator commented 2 years ago

Well, you're absolutely right. Thanks for taking the time to help with my jspsych-builder-unrelated problems. :bow: :upside_down_face: