Skip to content
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

No error when SVG for path doesn't exist #70

Open
strarsis opened this issue Apr 2, 2020 · 1 comment
Open

No error when SVG for path doesn't exist #70

strarsis opened this issue Apr 2, 2020 · 1 comment

Comments

@strarsis
Copy link

strarsis commented Apr 2, 2020

Currently, the plugin fails silently when an SVG file doesn't exist for the path.
Instead, the svg-loader(...) part is simply kept in the CSS output.

@agebhar1
Copy link

@strarsis I hit the same error. After some debugging I figured out that a race condition is the reason for the non replaced svg-loader(...). A Gulp based build process the SVG files and the CSS in parallel. The error occurs sporadic. The file exists but w/o content, so

function read(id) {
return new Promise((resolve, reject) => {
readFile(id, "utf-8", (err, data) => {
if (err) {
reject(Error(`Can't load '${id}'`));
} else {
resolve(data);
}
});
});
}

does not throw an error.

It was visible after adding some debugging code:

function read(id) {
    return new Promise(function (resolve, reject) {
        fs.readFile(id, 'utf-8', function (err, data) {

            var _data = fs.readFileSync(id)

            if (data === "") {
                console.error("Hit");
                console.log("async: " + data.length);
                console.log("sync:  " + _data.length);
            }

            if (err) {
                reject(Error(`Can't load '${id}'`));
            } else {
                resolve(data);
            }
        });
    });
}

The console shows in my case:

Hit
async: 0
sync:  5829

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants