Skip to content

Commit

Permalink
Improve config
Browse files Browse the repository at this point in the history
  • Loading branch information
icidasset committed Aug 6, 2020
1 parent ae4d54e commit 1135f71
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 86 deletions.
106 changes: 45 additions & 61 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
# -----
Expand All @@ -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 ; \
Expand All @@ -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"
Expand Down
36 changes: 11 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
5 changes: 5 additions & 0 deletions config/local-lobby.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"API_ENDPOINT": "https://runfission.net",
"DATA_ROOT_DOMAIN": "fissionuser.net",
"LOBBY": "http://localhost:8001"
}

0 comments on commit 1135f71

Please sign in to comment.