Giter Site home page Giter Site logo

Comments (6)

tcmulder avatar tcmulder commented on June 11, 2024

Oh, okay, I see what's going on. Whenever you run either npm run start or npm run build, WebpackConfigHelper.js wipes the entire dist folder, re-fills it, and regenerates the manifest.json. That's necessary for the development server to work: it's looking at the new manifest.json file to grab the in-development assets rather than the in-production dist assets that were there.

Maybe this is more of a feature request then, but would it be possible to have it not do that? Could node create a different folder somewhere and the PHP API connects to it if in development mode or something? It's just really a hassle to have the entire dist folder blown away whenever I save something in development. The dist folder shouldn't be something that's used for development purposes: it should be intended for production distribution after a build only. (See for example).

from wp-webpack-script.

swashata avatar swashata commented on June 11, 2024

Hi,

I don't understand why you'd want that though.

  1. Manifest changes on every development or build.
  2. The php package relies on the manifest for enqueuing proper assets.
  3. You shouldn't save the manifest on any database. Rather you should read it directly. The php package has API for that.

If you want the whole output to be saved somewhere except the dist directory, then change the option in wpackio.project.js file.

from wp-webpack-script.

swashata avatar swashata commented on June 11, 2024

Also, I will write some docs on how we can use wpackio for Gutenberg blocks. We are successfully using it in our team.

from wp-webpack-script.

tcmulder avatar tcmulder commented on June 11, 2024

Gutenberg docs would be helpful! I have it set up and working well for my blocks already, but it'd be excellent to see a more official setup for achieving that.

So, maybe I'm using the tool incorrectly and you could help me understand a better approach. I suppose my question tl;dr is, what URL do you use when you're adding content (especially images) within wp-admin?

How do you develop and then use blocks with the script paths always changing? I don't think it's good to access wp-admin through the IP address wpack.io gives me, because any images I upload for instance get saved like http://192.168.0.233:3000/wp-content/uploads/2021/06/example.jpg and only work while npm run start is running the wpack.io server. If my IP address changes, or a coworker does some work on the site over a different IP address, we'll end up with a bunch of broken image links that are using a variety of IP addresses all throughout the database. Those are still there when the wepback.io server isn't running: they're saved to the database as if it's running and aren't reachable if it's not.

Normally, I just access the site through whatever URL I set up through Docker or Local or MAMP, so every URL saved to the database is exactly the same and work without wpack.io running a development server (so http://example.test/wp-content/uploads/2021/06/example.jpg, with all URLs being under http://example.test). All my wp-admin work is done using that URL, so all URLs in the database are consistent and are easy to find and replace later for launch. My coworkers can use that same URL and not need to worry about what my IP address was the last time I was adding content.

However, right now, I can run the build, start entering content at http://example.test/wp-admin, notice I'd like some title's color to be blue instead of red or what have you, and as soon as I save that stylesheet, http://example.test/wp-admin reports all my wpack.io scripts as 404'ing and all my blocks as not being registered as a result. I'd much prefer http://example.test to keep working with the incorrect blue colored headings and wait for me to choose to run a build at the time I choose to, rather than having any development changes cause every block I've created to stop working.

Normally, running a development build should not cause any prior production build to stop working. I do a lot of Gatsby development: gatsby develop runs the development sever, but never touches the "dist" folder so the production code continues to work just fine; only when I run gatsby build does it update the "dist" folder. "Dist" is only used for distribution, i.e. production, and builds are triggered when the site's ready to go to production, not every save in development with most build tools I've used.

Is that making sense?

from wp-webpack-script.

swashata avatar swashata commented on June 11, 2024

Well you are right about that. But at this moment, I do not have the mileage to work on this change, as it sounds like a major thing. Among internal things, we have to somehow inform Wpackio\Enqueue about which directory to use dist or dev. And it has to be WordPress compliant. We cannot read some environment or arbitrary files to determine that.

But if you think you can come up with a solution, I will gladly review your PR and merge.

from wp-webpack-script.

tcmulder avatar tcmulder commented on June 11, 2024

Okay thanks, I'll see if I can get some time to look into it once my current project is nearing finish.

from wp-webpack-script.

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.