Last active
August 20, 2018 20:49
-
-
Save ooflorent/5dec643a2b20fafda832600394740692 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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