Giter VIP home page Giter VIP logo

Comments (8)

arctic-hen7 avatar arctic-hen7 commented on May 30, 2024

Hmm, that certainly sounds like a bug introduced in the rewrite, I'll take a look...

from perseus.

arctic-hen7 avatar arctic-hen7 commented on May 30, 2024

I've just tried this with the following code, which generates a file test.txt in the root of the project and then creates a static alias to it:

actions
    .settings_actions
    .add_static_aliases
    .register_plugin("test-plugin", |_, _| {
        let mut map = std::collections::HashMap::new();
        map.insert("/test".to_string(), "test.txt".to_string());
        Ok(map)
    });
#[cfg(engine)]
actions
    .export_actions
    .before_export
    .register_plugin("test-plugin", |_, _| {
        std::fs::write("test.txt", "Hello, world!").unwrap();
        Ok(())
    });

This seems to work fine for me, as it does when I change the path so the file is placed in dist/static (although you really shouldn't put things in there, since a user's pages could trivially override them and leave your app in a very strange state, I would strongly recommend putting them in the root of dist/, or, better, in a directory inside dist/ named according to your plugin's name).

What exactly is your problematic code, and what is the precise error you're receiving?

from perseus.

wingertge avatar wingertge commented on May 30, 2024

I haven't had time to properly investigate yet, I just got an issue from a user of perseus-tailwind and it didn't seem related to my code since normal builds work fine and I am hooking into before_export with the same code from build.
The code is here:
https://github.com/wingertge/perseus-tailwind/blob/master/src/lib.rs

I wait for the tailwind compiler process to exit before returning from the plugin so it should be done writing.
The output path is user defined by the way, I have no control over that. I just picked dist/static/tailwind.css as an example output path.

from perseus.

arctic-hen7 avatar arctic-hen7 commented on May 30, 2024

Hmm, is this on the latest beta?

from perseus.

wingertge avatar wingertge commented on May 30, 2024

I got around to doing more testing and it seems this is some weird behaviour from Command actually. output() should wait until the process has exited, but it only prints the pre-compile message so it's clearly returning before the actual compilation is run. Closing this and investigating what could be going on.

from perseus.

wingertge avatar wingertge commented on May 30, 2024

After further debugging, there was an error in my code but there also still seems to be an issue with perseus itself. I fixed my issue and I'm explicitly printing out whether the file exists after I run the compile step (it does), but it still says it's not there. This is just a hunch, but this feels like a path resolution issue, where regular build and export use different resolutions.

from perseus.

wingertge avatar wingertge commented on May 30, 2024

Ok I fixed it but this is definitely a bug. If the static alias points to /static/tailwind.css it fails, if it points to just /tailwind.css it succeeds. Something is breaking static aliases which host things at /static. The location of the file doesn't actually change anything, it's the server path that breaks it.

from perseus.

arctic-hen7 avatar arctic-hen7 commented on May 30, 2024

This is actually a much bigger issue: any nested static aliases will fail with exporting, because the directories needed for them are not created by the CLI core!

from perseus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.