Skip to content

Commit d09b1a4

Browse files
committed
initial build
0 parents  commit d09b1a4

File tree

10 files changed

+178
-0
lines changed

10 files changed

+178
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bin/

.travis.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
sudo: required
2+
dist: trusty
3+
4+
language: haxe
5+
6+
haxe:
7+
- "3.4.4"
8+
- "3.4.5"
9+
- "3.4.6"
10+
- "3.4.7"
11+
- "development"
12+
13+
matrix:
14+
allow_failures:
15+
- haxe: development
16+
17+
install:
18+
- npm install uglify-js
19+
- haxelib dev uglifyjs .
20+
21+
script:
22+
- haxe test.hxml
23+
24+
deploy:
25+
- provider: script
26+
haxe: 3.4.7
27+
script: bash ./releaseHaxelib.sh $HAXELIB_PWD
28+
on:
29+
tags: true

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Haxe/JavaScript Uglify
2+
3+
UglifyJS is a JavaScript parser, minifier, compressor and beautifier toolkit.
4+
5+
This library runs the [uglify-js node module](https://www.npmjs.com/package/uglify-js) after your Haxe/JavaScript build completed.
6+
7+
## Installation
8+
9+
First: Install the node module using NPM:
10+
11+
```
12+
npm install uglify-js --save
13+
```
14+
15+
Second: Install using [Haxelib](https://lib.haxe.org/p/uglifyjs/):
16+
17+
```
18+
haxelib install uglifyjs
19+
```
20+
21+
22+
To use in code, add to your build hxml:
23+
24+
```
25+
-lib uglifyjs
26+
27+
28+
# disable uglifyjs from being executed:
29+
-D uglifyjs_disabled
30+
31+
# overwrite original output rather then generating a .min.js next to it
32+
-D uglifyjs_overwrite
33+
```
34+

extraparams.hxml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--macro UglifyJS.run()

haxelib.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "uglifyjs",
3+
"url": "https://github.com/markknol/hx-uglifyjs",
4+
"license": "MIT",
5+
"tags": ["haxe","js","uglify","minify","obfuscation"],
6+
"description": "Minify using uglifyjs",
7+
"version": "0.0.1",
8+
"classPath": "src/",
9+
"releasenote": "Initial release",
10+
"contributors": [
11+
"markknol"
12+
],
13+
"dependencies": {
14+
15+
}
16+
}

releaseHaxelib.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
rm -f uglifyjs.zip
3+
zip -r uglifyjs.zip README.md src haxelib.json extraparams.hxml
4+
haxelib submit uglifyjs.zip $HAXELIB_PWD --always

src/UglifyJS.hx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import haxe.macro.Context;
2+
using StringTools;
3+
using haxe.io.Path;
4+
5+
class UglifyJS {
6+
public static function run() {
7+
if (!Context.defined("uglifyjs_disabled")) {
8+
Context.onAfterGenerate(function() {
9+
var args = Sys.args();
10+
var inPath = haxe.macro.Compiler.getOutput();
11+
if (!inPath.endsWith('.js')) {
12+
Context.warning('Expected .js extension for output file $inPath', Context.currentPos());
13+
} else {
14+
var outputPath = if (Context.defined("uglifyjs_overwrite")) '$inPath' else '${inPath.withoutExtension()}.min.js';
15+
Sys.command("node_modules/.bin/uglifyjs", ['--compress', '--mangle', '--output', '$outputPath', '--', '$inPath']);
16+
}
17+
});
18+
}
19+
}
20+
}

test.hxml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-main Main
2+
-cp src/
3+
-js bin/uglifyjs.js
4+
5+
-lib uglifyjs

test/Main.hx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package ;
2+
3+
/**
4+
@author $author
5+
**/
6+
class Main {
7+
public static function main() {
8+
new Main();
9+
}
10+
11+
public function new() {
12+
13+
}
14+
}

uglifyjs.hxproj

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<project version="2">
3+
<!-- Output SWF options -->
4+
<output>
5+
<movie outputType="CustomBuild" />
6+
<movie input="" />
7+
<movie path="build.hxml" />
8+
<movie fps="0" />
9+
<movie width="0" />
10+
<movie height="0" />
11+
<movie version="0" />
12+
<movie minorVersion="0" />
13+
<movie platform="hxml" />
14+
<movie background="#FFFFFF" />
15+
<movie preferredSDK="" />
16+
</output>
17+
<!-- Other classes to be compiled into your SWF -->
18+
<classpaths>
19+
<class path="src/" />
20+
</classpaths>
21+
<!-- Build options -->
22+
<build>
23+
<option directives="" />
24+
<option flashStrict="False" />
25+
<option noInlineOnDebug="False" />
26+
<option mainClass="Main" />
27+
<option enabledebug="False" />
28+
<option additional="" />
29+
</build>
30+
<!-- haxelib libraries -->
31+
<haxelib>
32+
33+
</haxelib>
34+
<!-- Class files to compile (other referenced classes will automatically be included) -->
35+
<compileTargets>
36+
<compile path="src\\Main.hx" />
37+
</compileTargets>
38+
<!-- Paths to exclude from the Project Explorer tree -->
39+
<hiddenPaths>
40+
<hidden path="bin/" />
41+
</hiddenPaths>
42+
<!-- Executed before build -->
43+
<preBuildCommand>cmd /c haxe $(OutputFile)</preBuildCommand>
44+
<!-- Executed after build -->
45+
<postBuildCommand alwaysRun="False"></postBuildCommand>
46+
<!-- Other project options -->
47+
<options>
48+
<option showHiddenPaths="False" />
49+
<option testMovie="Custom" />
50+
<option testMovieCommand="" />
51+
</options>
52+
<!-- Plugin storage -->
53+
<storage />
54+
</project>

0 commit comments

Comments
 (0)