Skip to content

Commit 3dc9e38

Browse files
authored
Merge pull request #8 from twitchdev/beta
Babel version bump
2 parents e813a90 + 9a47d06 commit 3dc9e38

File tree

8 files changed

+5183
-7382
lines changed

8 files changed

+5183
-7382
lines changed

README.md

Lines changed: 63 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,46 @@
1-
# Native React Boilerplate
1+
# Twitch Extension React Boilerplate
2+
- [Twitch Extension React Boilerplate](#twitch-extension-react-boilerplate)
3+
- [Requirements](#requirements)
4+
- [First time Usage](#first-time-usage)
5+
- [Developer Rig Usage](#developer-rig-usage)
6+
- [Local Development](#local-development)
7+
- [Loading the Sample on Twitch](#loading-the-sample-on-twitch)
8+
- [Moving to Hosted Test (and beyond!)](#moving-to-hosted-test-and-beyond)
9+
- [Webpack Config](#webpack-config)
10+
- [Authentication](#authentication)
11+
- [File Structure](#file-structure)
12+
- [dist](#dist)
13+
- [public](#public)
14+
- [src](#src)
215

316
## Requirements
417

518
There is only one requirement to use this template.
619

720
* Node.JS LTS or greater.
821

9-
You may also find that using `yarn` is easier than `npm`, so we do recommend installing that as well by running:
10-
```
11-
npm i -g yarn
12-
```
13-
in an elevated command line interface.
14-
15-
If you opt to use `npm`, simply replace all mentions of `yarn` below with `npm run`, such as `npm run start` or `npm run build`.
16-
1722
## First time Usage
1823

24+
There are two ways to develop extensions- the first is the [Developer Rig](#developer-rig-usage), which is the preferred option. The second is to use [Local Test](#local-development) and test on Twitch on your channel page.
25+
1926
### [Developer Rig](https://dev.twitch.tv/docs/extensions/rig/) Usage
2027

21-
If you are using the developer rig and have used this as your basis for your extension, please ignore the below steps- the developer rig has taken care of it for you!
28+
If you are using the [Developer Rig](https://dev.twitch.tv/docs/extensions/rig/) and have used this as your basis for your extension, this is easy to start with. The full steps are:
29+
30+
1. Click on Add Project, then Create Project
31+
2. Either create a new extension or use an existing one and hit "Next"
32+
3. Choose "Use boilerplate code" under "Add Code to your Project" and hit "Next"
33+
4. Let the boilerplate code download, install dependencies, and complete. Once finished, hit "Get Started"
34+
5. Click on "Run Frontend" and add views in the "Extension Views" tab
35+
6. Accept any certificate errors, as the certificate is self-signed
36+
7. You can now make changes in real-time and it'll update in all views!
2237

23-
### Please note that HTTPS only works with the Developer Rig version 1.1.4 and above.
38+
**Please note that HTTPS only works with the Developer Rig version 1.1.4 and above.**
2439

25-
If you are using a version below that, please either upgrade or disable HTTP. To do so:
40+
If you are using a version below that, please either upgrade the Developer Rig (by either auto-updating or reinstalling the Developer Rig) or disable HTTPS. To disable HTTPS:
2641

27-
1. Go into `/webpack.config.js`
28-
2. Update `config.devServer.https = true` to `config.devServer.https = false`
42+
1. Go into `/webpack.config.js`.
43+
2. Update `config.devServer.https = true` to `config.devServer.https = false`.
2944
3. On the [Twitch Developer Console](https://dev.twitch.tv/console), make sure to update the Asset Hosting path for your extension to use http instead.
3045
4. Refresh your manifest in the Developer Rig and recreate your views.
3146

@@ -34,25 +49,45 @@ If you are using a version below that, please either upgrade or disable HTTP. To
3449
If you're wanting to develop this locally, use the below instructions.
3550
To use this, simply clone the repository into the folder of your choice.
3651

37-
For example, to clone this into a `<repo name here>` folder, simply run the following in a commandline interface:
52+
For example, to clone this into a `extensions-boilerplate` folder, simply run the following in a command line interface:
3853
```
39-
git clone <repo name to be fixed later>
54+
git clone https://github.com/twitchdev/extensions-boilerplate
4055
```
4156

4257
Next, do the following:
4358

4459
1. Change directories into the cloned folder.
45-
2. Run `yarn install` to install all prerequisite packages needed to run the template.
46-
3. Run `yarn start` to run the sample. If everything works, you should be be able to go to the developer rig, create a panel view, and see `Hello world!`
60+
2. Run `npm install` to install all prerequisite packages needed to run the template.
61+
3. Run `npm run start` to run the sample. By default, you should be be able to go to `https://localhost:8080/` and have the page show the instructions to get up and running. This README includes that same information. This sample requires it be run on https://twitch.tv/ or the Twitch Developer Rig to utilize the Twitch Extension Helper.
62+
1. It should also give a certificate error- this is expected, as the sample uses a self-signed certificate to support HTTPS.
63+
2. If you had to change the port (likely due to a port conflict), update the port in the URL above.
4764

48-
## Building Production Files
65+
#### Loading the Sample on Twitch
4966

50-
To build your finalized React JS files, simply run `yarn build` to build the various webpacked files. These files will use code splitting to only load in the libraries needed for that view, while still allowing you to reuse components.
67+
1. Now that you have the boilerplate loaded and installed, you'll need two things first.
68+
* Extension made on [the Twitch Developer Site](https://dev.twitch.tv/console).
69+
* The extension installed on your own channel. This can be done in the "Invite Only" section of the Extension Store, where you'll find your extension listed.
70+
2. Once you've installed your extension, you'll need to activate the extension and add it to any of the available slots: Panel, Component, or Overlay. Do note that Component or Overlay extensions require you to be live when testing.
71+
3. Go to your channel on Twitch and you'll have to click on "Accept" on the extension. It should load.
72+
4. If it doesn't load, don't fret! Simply visit the URL for the view (https://localhost:8080/panel.html for a panel view, for example) and accept the certificate. Go back to your channel page on Twitch and you'll be good to go!
73+
74+
## Moving to Hosted Test (and beyond!)
75+
76+
When you are happy with how your extension looks locally, you can then move into Hosted Test on Twitch.
77+
78+
1. Twitch will host your frontend assets for you. To upload your frontend files, zip the _contents_ of your `dist` directory after running `npm run build`. **Note that the contents of the `dist` directory must be at the root of your zip file. If you have trouble viewing your extension please make sure that your files are not wrapped in a parent folder at the root of the zip file.**
79+
1. For OSX, you can run `zip -r ../dist.zip dist/*` in the `dist` folder to generate a properly formatted zip file.
80+
2. For Windows, you can select all files in the folder and add to compressed archive.
81+
2. From the [developer dashboard](https://dev.twitch.tv/console/extensions/) for your extension, navigate to the Files tab and upload your zip file. This could take a few minutes if your project is large.
82+
3. Once your front end files are uploaded, go back to the Status tab and click on "Move To Hosted Test".
83+
4. You should now be able to add your extension to your Twitch page and see what it looks like on your page. There is a handy link to do that in the dashboard using the "View on Twitch and Install" button!
5184

5285
### Webpack Config
5386

5487
The Webpack config is stored under `/webpack.config.js`. Adjusting the config will allow you to disable building code for unneeded extension views. To do so, simply turn the `build` attribute on the path to `false`.
5588

89+
One fairly important note is that the current configuration does not minimize the Webpack output. This is to help with the extension review policy, as turning this setting to minimize will guarantee that review will need full source to complete the review.
90+
5691
Additionally, feel free to modify the code as needed to add either additional plugins (via modifying the plugins variable at the top) or simply adjusting/tuning the output from Webpack.
5792

5893
### Authentication
@@ -80,23 +115,23 @@ window.Twitch.ext.onAuthorized(auth=>{
80115

81116
This then enables you to call a number of functions based on the token. The other functions are blind to whether the token is actually signed by Twitch, however, and should be only used for presentational purposes. Any requests to the backend should validate that the token is signed correctly by comparing signatures.
82117

83-
For a small demonstration of the class, see the App compoonent.
118+
For a small demonstration of the class, see the App component.
84119

85120
## File Structure
86121

87122
The file structure in the template is laid out with the following:
88123

89124
### dist
90125

91-
`/dist` holds the final JS files after building. You can simply zip up the contents of the folder to upload to Twitch to move to Hosted Test.
126+
`/dist` holds the final JS files after building. You can simply zip up the contents of the folder to upload to Twitch to move to Hosted Test, as noted above.
92127

93128
### public
94129

95-
`/public` houses the static HTML files used for your code's entrypoint. If you need to add new entrypoints (for something custom), simply add it to the webpack config and add a new copy of the file here.
130+
`/public` houses the static HTML files used for your code's entrypoint. If you need to add new entrypoints (for something custom, such as a specific view that's only for a subset of users), simply add it to the webpack config and add a new copy of the file here.
96131

97132
### src
98133

99-
This folder houses all source code and relevant files (such as images). Each React class/component is given a folder to house all associated files (such as associated CSS).
134+
This folder houses all source code and relevant files (such as images). Each React class/component is given a folder under `components` to house all associated files (such as associated CSS).
100135

101136
Below this folder, the structure is much simpler.
102137

@@ -108,12 +143,9 @@ components\
108143
--\App.js
109144
--\App.test.js
110145
--\App.css
111-
-\Authentication\
112-
--\Authentication.js
113146
...
114-
-\static\
115-
--\images
116-
---\sample_image.jpeg
147+
-\util\
148+
--\Authentication\
149+
---\Authentication.js
150+
---\Authentication.test.js
117151
```
118-
119-
Each component is under the `components` folder.

babel.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
presets: [
3+
["@babel/preset-env",
4+
{
5+
targets:{
6+
node:"current"
7+
}
8+
}]
9+
]
10+
}

0 commit comments

Comments
 (0)