diff --git a/Justfile b/Justfile index 6412554..a769686 100644 --- a/Justfile +++ b/Justfile @@ -4,74 +4,35 @@ export NODE_OPTIONS := "--no-warnings" # Variables # --------- -build_dir := "./build" -node_bin := "./node_modules/.bin" -src_dir := "./src" -sys_dir := "./system" +build_dir := "./build" +node_bin := "./node_modules/.bin" +src_dir := "./src" +sys_dir := "./system" -environment := "dev" -default_config := "config/default.json" -production_config := "config/production.json" +config := "default" # Tasks # ----- -@default: dev +@default: dev-build + just dev-server & just watch -@apply-config config=default_config: - echo "🎛 Applying config \`{{config}}\`" - {{node_bin}}/mustache {{config}} {{build_dir}}/index.html > {{build_dir}}/index.applied.html +@apply-config: + echo "🎛 Applying config \`config/{{config}}.json\`" + {{node_bin}}/mustache config/{{config}}.json {{build_dir}}/index.html > {{build_dir}}/index.applied.html rm {{build_dir}}/index.html mv {{build_dir}}/index.applied.html {{build_dir}}/index.html -@build: clean css-large html elm javascript-dependencies javascript meta images (_report "Build success") - - -@build-production: - just environment=production build css-small - - echo "⚙️ Minifying Javascript Files" - {{node_bin}}/terser-dir \ - {{build_dir}} \ - --each --extension .js \ - --patterns "**/*.js, !**/*.min.js" \ - --pseparator ", " \ - --output {{build_dir}} \ - -- --compress --mangle - - echo "⚙️ Minifying HTML Files" - {{node_bin}}/html-minifier-terser \ - --input-dir {{build_dir}} \ - --output-dir {{build_dir}} \ - --file-ext html \ - \ - --collapse-whitespace --remove-comments --remove-optional-tags \ - --remove-redundant-attributes \ - --remove-tag-whitespace --use-short-doctype \ - --minify-css true --minify-js true - - echo "⚙️ Creating a nomodule build" - {{node_bin}}/snowpack \ - --dest {{build_dir}}/web_modules \ - --optimize \ - --nomodule {{src_dir}}/Javascript/index.js \ - --nomodule-output nomodule.min.js - - rm {{build_dir}}/web_modules/*.map - - @clean: rm -rf {{build_dir}} mkdir -p {{build_dir}} -@dev: clean build - just dev-server & \ - just watch +@dev-build: clean css-large html apply-config elm javascript-dependencies javascript meta images (_report "Build success") @dev-server: @@ -104,6 +65,39 @@ production_config := "config/production.json" cp node_modules/fission-sdk/index.umd.js web_modules/fission-sdk.umd.js +@production-build: + just config=production build css-small + + echo "⚙️ Minifying Javascript Files" + {{node_bin}}/terser-dir \ + {{build_dir}} \ + --each --extension .js \ + --patterns "**/*.js, !**/*.min.js" \ + --pseparator ", " \ + --output {{build_dir}} \ + -- --compress --mangle + + echo "⚙️ Minifying HTML Files" + {{node_bin}}/html-minifier-terser \ + --input-dir {{build_dir}} \ + --output-dir {{build_dir}} \ + --file-ext html \ + \ + --collapse-whitespace --remove-comments --remove-optional-tags \ + --remove-redundant-attributes \ + --remove-tag-whitespace --use-short-doctype \ + --minify-css true --minify-js true + + echo "⚙️ Creating a nomodule build" + {{node_bin}}/snowpack \ + --dest {{build_dir}}/web_modules \ + --optimize \ + --nomodule {{src_dir}}/Javascript/index.js \ + --nomodule-output nomodule.min.js + + rm {{build_dir}}/web_modules/*.map + + # Parts # ----- @@ -121,7 +115,7 @@ production_config := "config/production.json" @elm: echo "⚙️ Compiling Elm" - if [ "{{environment}}" == "production" ]; then \ + if [ "{{config}}" == "production" ]; then \ elm make {{src_dir}}/Application/Main.elm --output={{build_dir}}/application.js --optimize ; \ else \ elm make {{src_dir}}/Application/Main.elm --output={{build_dir}}/application.js --debug ; \ @@ -136,16 +130,6 @@ production_config := "config/production.json" mkdir -p {{build_dir}}/reception cp {{src_dir}}/Static/Html/Reception.html {{build_dir}}/reception/index.html - just environment={{environment}} html-apply-config - - -@html-apply-config: - if [ "{{environment}}" == "production" ]; then \ - just apply-config \"{{production_config}}\" ; \ - else \ - just apply-config ; \ - fi - @images: echo "⚙️ Copying Images" diff --git a/README.md b/README.md index 42140a1..15611da 100644 --- a/README.md +++ b/README.md @@ -8,34 +8,20 @@ First-party application for your Fission filesystem. -## Quickstart +## Development + +This project uses Nix to manage the project's environment. If you'd like to build this project without Nix, check out the dependencies in the `shell.nix` file (most are available through Homebrew as well). ```shell -# 🍱 -# 1. Install programming languages -# (or install manually, see .tool-versions) -# (https://asdf-vm.com) -# `brew install asdf` -# `brew install gpg2` -asdf plugin-add elm -asdf plugin-add nodejs && bash ~/.asdf/plugins/nodejs/bin/import-release-team-keyring -asdf install - -# 2. Install https://github.com/casey/just -# `brew install just` -# 3. Install https://github.com/watchexec/watchexec -# `brew install watchexec` -# 4. Install https://github.com/cortesi/devd -# `brew install devd` -# 5. Install https://pnpm.js.org/ -# `brew install pnpm` -# 6. (optional) Install https://github.com/avh4/elm-format -# `brew install elm-format` - -# 7. Install dependencies +# Install javascript dependencies just install-deps -# 🛠 -# Build, watch & start server +# Build, watch & serve just + +# Production build +just production-build + +# Use a different config +just config=local-lobby dev-build ``` diff --git a/config/local-lobby.json b/config/local-lobby.json new file mode 100644 index 0000000..01f2eb2 --- /dev/null +++ b/config/local-lobby.json @@ -0,0 +1,5 @@ +{ + "API_ENDPOINT": "https://runfission.net", + "DATA_ROOT_DOMAIN": "fissionuser.net", + "LOBBY": "http://localhost:8001" +}