Skip to content

Commit 418e7ba

Browse files
committed
TypeScript support fixed
1 parent cc1a733 commit 418e7ba

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

README.md

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Create React WP Theme
22

3-
*UPDATED* to support create-react-app v2! (TypeScript doesn't work yet)
3+
*UPDATED* to support create-react-app v2, including TypeScript!
44

55
The intention of this project is to maintain a set of custom `react-scripts` that will allow you to
66
create React WordPress themes as easily as `create-react-app` allows other devs to create their apps.
@@ -19,11 +19,11 @@ To create a WordPress theme using the `create-react-wptheme`, follow these steps
1919
- Use `npx create-react-wptheme` to make a new theme
2020
- For example: (**replace "my_react_theme" with whatever you want your theme to be named**):
2121
- `npx create-react-wptheme my_react_theme`
22+
- If you want to use TypeScript, then the command would be:
23+
- `npx create-react-wptheme my_react_theme --typescript`
2224
- When it finishes it'll tell you to change into your new theme's folder and run the Nodejs watcher (replace "my_react_theme" with the same name you used in the previous step):
2325
- `cd my_react_theme/react-src`
2426
- `npm run wpstart`
25-
- or if you have yarn installed:
26-
- `yarn wpstart`
2727
- That sets up the theme so that it can be seen in the WordPress admin area.
2828
- **Go there now and set your WordPress site to use this theme.**
2929
- View the site in your browser with the new theme.
@@ -33,7 +33,7 @@ To create a WordPress theme using the `create-react-wptheme`, follow these steps
3333
- **You can revoke write access after the setup has completed.**
3434
- Interested (paranoid?) about what it's doing? Check out the file: `<your theme folder name>/index.php`
3535
- When that's done the theme tells you to `Please restart the Nodejs watcher now...`
36-
- To do that, go back to your command prompt where you first ran `npm run wpstart` or `yarn wpstart` and rerun that same command again.
36+
- To do that, go back to your command prompt where you first ran `npm run wpstart` and rerun that same command again.
3737
- In a few seconds you should see your browser load with the standard create-react-app page, but it's running as a WordPress theme!
3838

3939
## Coding with React
@@ -72,7 +72,7 @@ that you can mess with if you need to.
7272

7373
### Build Configuration
7474

75-
The `react-src/user.prod.json` configuration file is read when you run `npm run wpbuild` (or `yarn wpbuild`). The only option in there is setting the "homepage"
75+
The `react-src/user.prod.json` configuration file is read when you run `npm run wpbuild`. The only option in there is setting the "homepage"
7676
which controls the relative linking to files in your theme. The "homepage" setting in your main `package.json` file is used during development (and build by default).
7777
During development, this is probably what you want. But if you know your production server will have a different root, then you can set the homepage to be different during
7878
a production build.
@@ -85,7 +85,7 @@ For example:
8585
- But you know that your production server runs WordPress from the root: http<nolink>://mycoolblog.com/
8686
- In this case you want to remove the `/wordpress` part, so set the "homepage" line in your `user.prod.json` file to:
8787
`"homepage": "/wp-content/themes/<your theme's folder name>"`
88-
- Then run `npm run wpbuild` (or `yarn wpbuild`)
88+
- Then run `npm run wpbuild`
8989
- Note that if you then view your theme on your dev server, it will most likely be broken. But will hopefully look
9090
correct on your production server.
9191

@@ -124,7 +124,6 @@ To configure the Browser Refresh Server to use SSL, follow these steps:
124124
- All OSes: `cd ..`
125125
- Start Node/Webpack JS watcher as you normally would:
126126
- All OSes: `npm run start`
127-
- Or if you use Yarn: `yarn start`
128127
- Your theme should open in a new browser tab
129128
- If you need to add an SSL exception to your browser for your new certificate, there is a page running over HTTPS at the "host" and "port" you set in `user.dev.json` above.
130129
- For example, if you're using host `127.0.0.1` and port `8090` as shown above, then open your browser to:
@@ -147,14 +146,10 @@ To configure the Browser Refresh Server to use SSL, follow these steps:
147146
- Touch the original `react-scripts` as little as possible.
148147
- Add new files where possible.
149148
- This will make merges easier.
150-
- Don't laugh at things like the "return" jammed right in the middle of `init.js`.
151-
- [line 113](https://github.com/devloco/react-scripts-wptheme/blob/master/scripts/init.js)
152-
- Seriously, I have no idea what the next version of `react-scripts` is going to look like, but I bet that will merge nice-n-easy.
153149
- However, something worse than merge conflicts is confusing users.
154150
- If completely munging one of the original files will lower the number of support issues... do it!
155151
- Example: renaming all the original `create-react-app` scripts by prefixing them with "cra" (e.g. crastart, craeject, etc.)
156-
will stop users that are used to typing `yarn start` (you should be using `yarn wpstart` instead) and muscle memory-izing
157-
themselves into confusion.
152+
will stop ensure users don't accidentally start the Webpack Dev Server, but still allows them to.
158153

159154
## Acknowledgements
160155

createReactWpTheme.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,11 @@ function createApp(
208208
console.log();
209209

210210
let useYarn = useNpm ? false : shouldUseYarn();
211-
const originalDirectory = process.cwd();
211+
useYarn = false; // always use NPM for now.
212212

213+
const originalDirectory = process.cwd();
213214
process.chdir(root); // change into the newly created folder, then run create-react-app.
214215

215-
useYarn = false; // always use NPM for now.
216216
createWpTheme(
217217
root,
218218
appName,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "create-react-wptheme",
3-
"version": "2.1.1-wptheme-2.0.8",
3+
"version": "2.1.1-wptheme-2.0.9",
44
"description": "Create React WP themes with no build configuration.",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)