Add webpack build stage to deal with current limitations of workers platform

This commit is contained in:
Gonçalo Valério 2023-06-30 19:44:29 +01:00
parent e9795343e6
commit a4e1dece04
Signed by: dethos
GPG Key ID: DF557F2BDCC2445E
6 changed files with 4610 additions and 7 deletions

1
.gitignore vendored
View File

@ -9,3 +9,4 @@ worker/
node_modules/
.cargo-ok
wrangler.toml
.wrangler

View File

@ -21,7 +21,10 @@ This ends up being specially useful for communities, in order to follow the work
4. Create KV namespaces and add their ids to the `kv_namespaces` setting on `wrangler.toml`
5. Add your `account_id` and customize all the `vars` in `wrangler.toml`. `FEEDS` should be
a string of coma separated urls, to each of the RSS/ATOM sources that will be part of your planet.
6. Run `wrangler deploy`
6. Build the worker bundle: `npm run build`
7. Deploy your new worker: `npm run deploy`
**Note:** For the last step you might need to set the `CLOUDFLARE_API_TOKEN` environment variable.
## Configuration variables

4589
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -5,9 +5,9 @@
"description": "Generate a single feed of content from multiple RSS/Atom sources. Runs on Cloudflare Workers.",
"main": "./index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"format": "prettier --write '**/*.{js,css,json,md}'",
"format": "prettier --write '**/*.{js,css,json,md}' '!**/worker/*' '!**/templates/*'",
"template": "handlebars -c handlebars/runtime",
"build": "webpack",
"dev": "wrangler dev",
"deploy": "wrangler deploy"
},
@ -15,11 +15,14 @@
"license": "AGPL-3.0",
"devDependencies": {
"prettier": "^1.18.2",
"wrangler": "^3.1.1"
"webpack": "^4.46.0",
"webpack-cli": "^4.10.0",
"wrangler": "^3.1.1",
"wranglerjs-compat-webpack-plugin": "^0.0.6"
},
"dependencies": {
"feed": "^4.2.2",
"handlebars": "^4.7.7",
"rss-parser": "^3.13.0"
}
}
}

9
webpack.config.js Normal file
View File

@ -0,0 +1,9 @@
const path = require('path')
const {
WranglerJsCompatWebpackPlugin,
} = require('wranglerjs-compat-webpack-plugin')
module.exports = {
entry: './index.js',
plugins: [new WranglerJsCompatWebpackPlugin()],
}

View File

@ -1,5 +1,5 @@
name = "worker-planet"
main = "index.js"
main = "./worker/script.js"
compatibility_date = "2023-05-18"
node_compat = true
account_id = ""