Run a nodejs script right before website is deployed to transform the website's content
my website is multilingual, and i do it by running a script on my project that transforms it into multiple folders, each for a different language.
I run that script during development to view my website, but is there a way to do that in cloudflare?
12 Replies
Can post that script is necessary. The project version im talking about isnt deployed to cloudflare yet, but can be found in the repository:
https://github.com/ShaharMS/APBD-FoodList/tree/qol/main-site-integration
GitHub
GitHub - ShaharMS/APBD-FoodList at qol/main-site-integration
Lists of foods sorted by glycemic indices, glycemic loads, suger & carbs. - GitHub - ShaharMS/APBD-FoodList at qol/main-site-integration
the script in question: (ignore the script's persistency, a diffenret version of the script will be the one run by cloudflare:)
Hi @ShaharMS ,
You can configure a build command to run the build script for your project when you set up a pages site in Cloudflare.
https://developers.cloudflare.com/pages/configuration/build-configuration/
The
npm build
command can call tools installed inside your project if you have a build
script in your package.json like thisCloudflare Docs
Build configuration | Cloudflare Pages docs
You may tell Cloudflare Pages how your site needs to be built as well as where its output files will be located.
GitHub
jldec.me/package.json at main · jldec/jldec.me
https://jldec.me/. Contribute to jldec/jldec.me development by creating an account on GitHub.
Thanks, rn I'm at work but will test this when I get home :)
Ok, either i misunderstood or its not specifically what im asking for - i dont see any option for providing my own build tool - only run specific build commands for specific frameworks.
this project is vanilla html-css-js, so there arent any framework, and I have a build script that writes generates files.
To simplify my question - is there a way to get cloudflare to run
node .\compiler\auto-compile.mjs
, wait for it to finish, and then grab an output folder and use it as a site?did you try entering that full node command as your "build" command in the pages settings?
but will it actually permit it? it does filesystem stuff
just havent seen anything specific in the doc
yeah pages builds run in a linux container
Cloudflare Docs
Language support and tools | Cloudflare Pages docs
Cloudflare Pages’ build environment has broad support for a variety of languages, such as Ruby, Node.js, Python, PHP, and Go.
damn well ill try that and get back to u
will take me some time since i need to move stuff around and edit abit
no worries - good luck
Did everything - Tysm it worked :D
very surprising, wasnt thinking it would actually let me do filesystem changes
didnt know cloudflare was chill like that