This repository has been archived by the owner on Jul 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.bat
65 lines (52 loc) · 2.12 KB
/
build.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
:: NOTE: The Lisa's builder requires Node.js with the 'node-sass', 'babel-cli',
:: 'babel-preset-es2015' and 'uglify-js' modules
:: NOTE: The 'jsdox' module is required to generate the API documentation
@echo off
:: If asked for, watch the 'src' folder
:: Run the Node.js demon
if "%1" == "watch" call nodemon --watch src --exec "build.bat %2"
if "%1" == "watch" goto end
:: Console
echo [ build ] Fusionning all SCSS stylesheets...
:: Reset the file
echo. > build\lisa.scss
:: For each source file (JavaScript), bundle it
for %%f in (src\scss\*.scss) do (
type %%f >> build\lisa.scss
)
:: Transpile to CSS
echo [ build ] Transpiling to CSS...
call node-sass build\lisa.scss --output-style=compressed > build\lisa.min.css
:: Console
echo [ build ] Fusionning all ES6 scripts...
:: Enable strict mode in the bundle
echo "use strict"; > build\lisa-es6.js
:: Bundle every single file in the 'src\es6' folder
type src\es6\core.js >> build\lisa-es6.js
type src\es6\utils.js >> build\lisa-es6.js
type src\es6\localdata.js >> build\lisa-es6.js
type src\es6\web-interface.js >> build\lisa-es6.js
type src\es6\lis-parser.js >> build\lisa-es6.js
:: Babelify the ES6 bundle to make an ES5 one
:: That extends the game's compatibility with older browsers, with no ES6 support
cd build
echo [ build ] Transpiling to ES5...
:: Transpile the JavaScript ES6 bundle to ES5
call babel lisa-es6.js --out-file lisa-es5.js --presets=es2015
echo [ build ] Minifying...
:: If minifying is not forbidden, do it
if NOT "%1" == "--beautify" call uglifyjs --compress --mangle --output lisa.min.js -- lisa-es5.js
:: Else, don't minify the ES5 code
if "%1" == "--beautify" copy lisa-es5.js lisa.min.js
:: Return to the root directory
cd ..
:: If asked for, remove sources
if NOT "%1" == "--sources" echo [ build ] Removing sources...
if NOT "%1" == "--sources" del build\lisa-es6.js
if NOT "%1" == "--sources" del build\lisa-es5.js
if NOT "%1" == "--sources" del build\lisa.scss
:: If asked for, generate documentation
if "%1" == "--generate-doc" echo [ build ] Generating documentation...
if "%1" == "--generate-doc" call jsdox src\es6\core.js --output docs\API
:end
:: Done