You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.MD
+21-12Lines changed: 21 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,18 @@
1
1
# Webpack Boilerplate for Cloudflare Workers
2
2
3
-
A superbly simple minimal-config template for building, bundling and deploying Cloudflare Workers with Webpack 🚀
3
+
A superbly simple, minimal-config template for building, bundling and deploying Cloudflare Workers with Webpack 🚀
4
4
5
5

6
6
7
-
Webpack can seem like voodoo to the unfamiliar, so the goal here is to provide a reusable boilerplate with sane default configuration that allows anyone to bundle up a worker script with any NPM dependencies, and upload directly to Cloudflare.
7
+
8
+
9
+
------
10
+
11
+
12
+
13
+
Webpack can seem like voodoo to those unfamiliar with its infamous config 💀
14
+
15
+
So the goal here is to provide an easy-to-use template — with sane default settings — that'll bundle up your worker script with its `require()`'ed npm modules, upload it to Cloudflare, and even activate its route(s).
8
16
9
17
### What you configure:
10
18
- Your Cloudflare credentials
@@ -15,13 +23,13 @@ Webpack can seem like voodoo to the unfamiliar, so the goal here is to provide a
15
23
- Transparent, optimized and ready-to-rock Webpack configuration file
16
24
- Babel configuration ensuring development-setup build compatibility for Node 6 and up
17
25
- Babel-assured compatibility for Worker's JavaScript in the latest CF-Worker (i.e. Chrome) runtime
18
-
-Dynamic polyfilling, applied only when needed (which is anyways very unlikely!)
26
+
-On-demand polyfilling in the (very unlikely) event that it's needed
19
27
- Baked-in **management of route matching patterns**, if and when routes are provided
20
28
- Minification of deployed Worker scripts to help keep them under the 1MB limit
21
-
- A ready-to-deploy example Worker in worker.js using `require()`, with comments to help make sense of it all
29
+
- A deployable example Worker featuring `require()`, and with comments to help make sense of it all
22
30
23
31
### Requirements:
24
-
-Min. Node version 6
32
+
-Minimum Node.js version 6
25
33
26
34
## Quick Start
27
35
@@ -31,12 +39,12 @@ Webpack can seem like voodoo to the unfamiliar, so the goal here is to provide a
31
39
32
40
cd cloudflare-worker-webpack-boilerplate
33
41
````
34
-
2. Rename `example.env` to `.env` , and add your required Cloudflare credentials, and either your site name or zone-id.
42
+
2. Rename `example.env` to `.env` , and add your required Cloudflare credentials, and either your site name or site's zone-id.
35
43
3. Install dependencies with `npm install`
36
44
4. Write your worker script in `src/worker.js`
37
-
- Add any dependencies for your worker with: `npm install -P <some-required-package>`
38
-
- Build a preview of your bundled worker script (found in`dist/bundled-worker.js`) by running: `npm run build`
39
-
5. Build, bundle and launch your Worker to the Cloudflare edge 🚀 using: `npm run deploy`
45
+
- Install any dependencies for your worker with: `npm install -P <some-npm-module>`
46
+
- Build a preview of your bundled worker script in `dist/bundled-worker.js` by running: `npm run build`
47
+
5. Build, bundle and launch your ~~minion~~ Worker to the Cloudflare Edge 🚀 using: `npm run deploy`
40
48
41
49
42
50
### Example Cloudflare Worker
@@ -54,8 +62,9 @@ It then adds a response header in the form of:
54
62
55
63
#### Using the Example Worker
56
64
57
-
After completing steps 1-3 above, you can build the example script with `npm run build:example`,
58
-
or even deploy it to production with `npm run deploy:example`
65
+
After completing steps 1-3 above, you can build the example script with `npm run build:example`
66
+
67
+
You can even deploy it live to your site with `npm run deploy:example`
59
68
60
69
61
70
## Configuration
@@ -78,7 +87,7 @@ You **must** provide a means of identifying your Cloudflare site deployment targ
78
87
79
88
or
80
89
81
-
- `CLOUDFLARE_SITE_NAME`: The fully qualified domain name (FQDN) of your site
90
+
- `CLOUDFLARE_SITE_NAME`: The fully qualified domain name (FQDN) of your site, e.g. _example.lol_
0 commit comments