混淆步骤
项目文件结构
tool文件下
earth项目结构(requirejs项目)
1.安装nodeJS
2.下载一个requireJS ,这个是压缩文件
这个是用requirejs开发的r.js文件发布到earth-build下面,然后在发布的文件下面进行混淆
这一步在tool文件下有个bat文件,双击就可以了。
start.bat
node r.js -o build.js optimize=none
build.js
{
"appDir": "../earth",
"baseUrl": "scripts",
"dir": "../earth-build",
//Comment out the optimize line if you want
//the code minified by UglifyJS
"optimize": "none",// point to the shim config we set up before
"mainConfigFile": "../earth/scripts/app.js", "modules": [
//Optimize the application files. jQuery and the plugins will be included
//automatically, as they are dependencies of app.js.
{
"name":"app"
}
]
}
server.js
/*
* node static file server:
* modified from https://gist.github.com/rpflorence/701407
*/
/*jslint evil: true, nomen: true, sloppy: true */var http = require('http'),
url = require('url'),
path = require('path'),
fs = require('fs'),
port = process.argv[2] || 8888,
types = {
'html': 'text/html',
'js': 'application/javascript'
},
site = 'http://localhost:' + port;http.createServer(function (request, response) {
var uri = url.parse(request.url).pathname,
filename = path.join(__dirname, '..', uri);fs.exists(filename, function (exists) {
if (!exists) {
response.writeHead(404, {'Content-Type': 'text/plain'});
response.write('404 Not Found\n');
response.end();
return;
}if(!fs.lstatSync(filename).isDirectory()) {
var type = filename.split('.');
type = type[type.length - 1];response.writeHead(200, { 'Content-Type': types[type] + '; charset=utf-8' });
fs.createReadStream(filename).pipe(response);
} else {
/**
* if users visit the site such as http://localhost:8888
* then lead them to http://localhost:8888/www/app.html
*/
response.writeHead(301, {'Location': site + '/www/app.html' });
response.end();
}
});
}).listen(parseInt(port, 10));
console.log('Static file server running at\n => ' + site + '/\nCTRL + C to shutdown');
index.html
3.npm install uglifyjs
4.然后就可以双击bat文件了。它是在当前文件下搜索js文件进行混淆。
——————————————————————————————————————
以上文章仅供学习参考,有任何侵权问题,请联系本人!原创文章默认开启打赏,任何钱财法律纠纷概不负责。