Git Product home page Git Product logo

Comments (3)

koute avatar koute commented on August 20, 2024

That's how it works; it just that the src/static directory currently only works for bin crates. (This is a historical artifact as originaly cargo-web supported only *-emscripten targets, and there you can only use bin crates.) Are you perhaps using a lib or a cdylib crate?

You can put a static directory in the root of your crate instead of in src and that will work for all crate types.

from cargo-web.

ndarilek avatar ndarilek commented on August 20, 2024

Ah, I am in fact using a lib crate, with the lib as the core to my binary. I wonder if there's any way to make that clearer? Or is there some reason that src/static and static/ aren't treated identically, other than that cargo-web used to behave differently? Maybe just combine the contents of all static/ directories into target/deploy/?, or error out if both static/ and src/static/ exist?

I'd be happy to try implementing one or both of these, just want to know which direction you'd like to go in.

from cargo-web.

koute avatar koute commented on August 20, 2024

Well, I think it would make sense to support src/static for lib crates too now that wasm32-unknown-unknown can be compiled as a cdylib crate.

Currently cargo-web takes static artifacts from two places (in this specific order):

  • a target specific static directory (for bin crates this is src/static, for examples this is examples/$example_name-static)
  • $crate_root/static - a global directory for all artifacts in your crate (so, binaries, libs, examples, etc.)

If it finds an artifact in the target specific path then it stops looking further. The idea was that if you have multiple things in your crate then you can put the common stuff in static, and thing-specific stuff in the respective target specific static directory, and have that "merged" together when running start or deploy.

from cargo-web.

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.