I've been working on a small web project using the create-js-app
tool. I am attempting to load a file named test.txt
from my src
directory.
Here is the code from my main.js
file:
import * as THREE from 'three';
const loader = new THREE.FileLoader();
loader.load(
"test.txt",
function (data) {
console.log(data);
},
function (xhr) {
console.log(
"Loading file : " +
(xhr.loaded / xhr.total) * 100 +
"% loaded"
);
},
function (err) {
console.error(err);
}
);
However, when I run my site in Chrome, instead of getting the content of my test.txt
file, I am seeing the content of my index.html
file. I have spent quite some time trying to figure out why this is happening with no luck.
Even if I specify a different file path in the first argument of the loader.load()
function, I still end up with the content of index.html
. I have even tried specifying a nonexistent file as the path.
Has anyone else encountered this issue before?
Thank you for any help.
Edit: Just to clarify, I am using Parcel as the bundler for this project.