Skip to content

Instantly share code, notes, and snippets.

@ooflorent
Last active August 20, 2018 20:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ooflorent/5dec643a2b20fafda832600394740692 to your computer and use it in GitHub Desktop.
Save ooflorent/5dec643a2b20fafda832600394740692 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
# Clean previous build
rm -rf dist
mkdir dist
# Compile the game
$(yarn bin)/rollup -c \
-i src/index.js \
-o dist/game.js
$(yarn bin)/terser dist/game.js -o dist/game.js \
--ecma 8 \
--compress passes=4,pure_getters,unsafe,unsafe_arrows,unsafe_math \
--mangle \
--mangle-props keep_quoted \
--module
# Inline external resources
$(yarn bin)/html-inline \
-i public/index.html \
-o dist/index.html \
-b dist
# Minify the HTML page
$(yarn bin)/html-minifier dist/index.html -o dist/index.html \
--collapse-whitespace \
--minify-css \
--remove-attribute-quotes \
--remove-optional-tags
# Generate an optimized ZIP archive
zip -jqX9 dist/game.zip dist/index.html
advzip -z4q -i 10 dist/game.zip
#!/bin/bash
set -e
# Clean previous build
rm -rf dist
mkdir dist
# Copy assets
cp -R public/* dist
# Start the server and watch the code
$(yarn bin)/serve dist & $(yarn bin)/rollup -c -w \
--environment DEBUG \
-i src/index.js \
-o dist/game.js
{
"private": true,
"license": "MIT",
"scripts": {
"dev": "dev.sh",
"build": "build.sh"
},
"devDependencies": {
"html-inline": "^1.2.0",
"html-minifier": "^3.5.19",
"rollup": "^0.64.1",
"rollup-plugin-glsl": "^1.2.0",
"rollup-plugin-replace": "^2.0.0",
"serve": "^9.6.0",
"terser": "^3.8.1"
}
}
import glsl from "rollup-plugin-glsl"
import replace from "rollup-plugin-replace"
let { DEBUG } = process.env
export default {
output: {
format: "iife",
sourcemap: DEBUG,
},
plugins: [
glsl(),
replace({
__DEV__: DEBUG,
}),
],
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment