Coder Social home page Coder Social logo

Comments (5)

michaelsoriano avatar michaelsoriano commented on August 27, 2024 1

No biggie on the precache files. Its not harming anyone - it just gets messy. Especially when checking stuff in to git.

I'm going to follow the import route for images.

Global vars - I'm going to follow your advice by adding it to index.php. I'm only going to need a few of these vars. The wp_enqueue_script route is good too - but for now, I want to keep it simple.

Thanks again.

from create-react-wptheme.

devloco avatar devloco commented on August 27, 2024

I never noticed the manifest files, I'll look at what Facebook is doing about it, and try to follow suit. I know they are onboard with having that stuff around... I think they have something to do with Web Apps on mobile devices... I think... and if that's the case, they're a lot less interesting to WP themes. So I could probably diverge from Facebook in that case and whack them after a build.

As for static images, here's how Facebook thinks it should be done:

Adding Images, Fonts, and Files
Using the Public Folder

I would use the $TEMPLATE_PATH instead of %PUBLIC_URL% for linking to files in the public folder, if you go that route. It'll probably take some hunting to figure out exactly where everything gets copied to during a build.

To make the $TEMPLATE_PATH available to React, I would just add it as a global script at the top of index.php, like so:

<script> var TEMPLATE_PATH = "<?php echo $TEMPLATE_PATH; ?>"; </script>

Then you should be able to reference TEMPLATE_PATH anytime in any JS/React/etc.

from create-react-wptheme.

devloco avatar devloco commented on August 27, 2024

Also, this article was the inspiration for me to write create-react-wptheme and the author has a good section on getting PHP variables into React:

How To Build A Skin For Your Web App With React And WordPress

Smashing Magazine doesn't seem to support linking to a particular section of their articles. So you'll have to search that page for: A Global JavaScript Variable to get right to that part.

from create-react-wptheme.

devloco avatar devloco commented on August 27, 2024

Hi @michaelsoriano,

The multiple precache files was indeed on me. It should be fixed now. Here's the obligatory link to the update instructions:

Updating Existing Themes

Thanks for the help with bug hunting!

from create-react-wptheme.

michaelsoriano avatar michaelsoriano commented on August 27, 2024

Awesome @devloco! will update asap. Thanks.

from create-react-wptheme.

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.