Adds make minified command
This commit is contained in:
parent
6c3bdd144a
commit
2b298a7a34
79
make.js
79
make.js
@ -38,6 +38,7 @@ var ROOT_DIR = __dirname + '/', // absolute path to project's root
|
|||||||
LOCALE_SRC_DIR = 'l10n/',
|
LOCALE_SRC_DIR = 'l10n/',
|
||||||
GH_PAGES_DIR = BUILD_DIR + 'gh-pages/',
|
GH_PAGES_DIR = BUILD_DIR + 'gh-pages/',
|
||||||
GENERIC_DIR = BUILD_DIR + 'generic/',
|
GENERIC_DIR = BUILD_DIR + 'generic/',
|
||||||
|
MINIFIED_DIR = BUILD_DIR + 'minified/',
|
||||||
REPO = 'git@github.com:mozilla/pdf.js.git',
|
REPO = 'git@github.com:mozilla/pdf.js.git',
|
||||||
PYTHON_BIN = 'python2.7',
|
PYTHON_BIN = 'python2.7',
|
||||||
MOZCENTRAL_PREF_PREFIX = 'pdfjs',
|
MOZCENTRAL_PREF_PREFIX = 'pdfjs',
|
||||||
@ -53,6 +54,7 @@ var DEFINES = {
|
|||||||
MOZCENTRAL: false,
|
MOZCENTRAL: false,
|
||||||
B2G: false,
|
B2G: false,
|
||||||
CHROME: false,
|
CHROME: false,
|
||||||
|
MINIFIED: false,
|
||||||
SINGLE_FILE: false
|
SINGLE_FILE: false
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -390,6 +392,83 @@ function cleanupJSSource(file) {
|
|||||||
content.to(file);
|
content.to(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// make minified
|
||||||
|
// Builds the minified production viewer that should be compatible with most
|
||||||
|
// modern HTML5 browsers. Requires Google Closure Compiler.
|
||||||
|
//
|
||||||
|
target.minified = function() {
|
||||||
|
var compilerPath = process.env['CLOSURE_COMPILER'];
|
||||||
|
if (!compilerPath) {
|
||||||
|
echo('### Closure Compiler is not set. Specify CLOSURE_COMPILER variable');
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
target.bundle({});
|
||||||
|
target.locale();
|
||||||
|
|
||||||
|
cd(ROOT_DIR);
|
||||||
|
echo();
|
||||||
|
echo('### Creating minified viewer');
|
||||||
|
|
||||||
|
rm('-rf', MINIFIED_DIR);
|
||||||
|
mkdir('-p', MINIFIED_DIR);
|
||||||
|
mkdir('-p', MINIFIED_DIR + BUILD_DIR);
|
||||||
|
mkdir('-p', MINIFIED_DIR + '/web');
|
||||||
|
|
||||||
|
var defines = builder.merge(DEFINES, {GENERIC: true, MINIFIED: true});
|
||||||
|
|
||||||
|
var setup = {
|
||||||
|
defines: defines,
|
||||||
|
copy: [
|
||||||
|
[COMMON_WEB_FILES, MINIFIED_DIR + '/web'],
|
||||||
|
['web/viewer.css', MINIFIED_DIR + '/web'],
|
||||||
|
['web/compressed.tracemonkey-pldi-09.pdf', MINIFIED_DIR + '/web'],
|
||||||
|
['web/locale', MINIFIED_DIR + '/web']
|
||||||
|
],
|
||||||
|
preprocess: [
|
||||||
|
[BUILD_TARGETS, MINIFIED_DIR + BUILD_DIR],
|
||||||
|
[COMMON_WEB_FILES_PREPROCESS, MINIFIED_DIR + '/web']
|
||||||
|
]
|
||||||
|
};
|
||||||
|
builder.build(setup);
|
||||||
|
|
||||||
|
var viewerFiles = [
|
||||||
|
'web/compatibility.js',
|
||||||
|
'external/webL10n/l10n.js',
|
||||||
|
MINIFIED_DIR + BUILD_DIR + 'pdf.js',
|
||||||
|
MINIFIED_DIR + '/web/viewer.js'
|
||||||
|
];
|
||||||
|
var cmdPrefix = 'java -jar \"' + compilerPath + '\" ' +
|
||||||
|
'--language_in ECMASCRIPT5 ' +
|
||||||
|
'--warning_level QUIET ' +
|
||||||
|
'--compilation_level SIMPLE_OPTIMIZATIONS ';
|
||||||
|
|
||||||
|
echo();
|
||||||
|
echo('### Minifying js files');
|
||||||
|
|
||||||
|
exec(cmdPrefix + viewerFiles.map(function(s) {
|
||||||
|
return '--js \"' + s + '\"';
|
||||||
|
}).join(' ') +
|
||||||
|
' --js_output_file \"' + MINIFIED_DIR + '/web/pdf.viewer.js\"');
|
||||||
|
exec(cmdPrefix + '--js \"' + MINIFIED_DIR + '/build/pdf.js' + '\" ' +
|
||||||
|
'--js_output_file \"' + MINIFIED_DIR + '/build/pdf.min.js' + '\"');
|
||||||
|
exec(cmdPrefix + '--js \"' + MINIFIED_DIR + '/build/pdf.worker.js' + '\" ' +
|
||||||
|
'--js_output_file \"' + MINIFIED_DIR + '/build/pdf.worker.min.js' + '\"');
|
||||||
|
|
||||||
|
echo();
|
||||||
|
echo('### Cleaning js files');
|
||||||
|
|
||||||
|
rm(MINIFIED_DIR + '/web/viewer.js');
|
||||||
|
rm(MINIFIED_DIR + '/web/debugger.js');
|
||||||
|
rm(MINIFIED_DIR + '/build/pdf.js');
|
||||||
|
rm(MINIFIED_DIR + '/build/pdf.worker.js');
|
||||||
|
mv(MINIFIED_DIR + '/build/pdf.min.js',
|
||||||
|
MINIFIED_DIR + '/build/pdf.js');
|
||||||
|
mv(MINIFIED_DIR + '/build/pdf.worker.min.js',
|
||||||
|
MINIFIED_DIR + '/build/pdf.worker.js');
|
||||||
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Extension stuff
|
// Extension stuff
|
||||||
|
3
web/viewer-snippet-minified.html
Normal file
3
web/viewer-snippet-minified.html
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<!-- This snippet is used in production, see Makefile -->
|
||||||
|
<link rel="resource" type="application/l10n" href="locale/locale.properties"/>
|
||||||
|
<script type="text/javascript" src="pdf.viewer.js"></script>
|
@ -35,7 +35,7 @@ limitations under the License.
|
|||||||
<link rel="resource" type="application/l10n" href="locale/locale.properties"/>
|
<link rel="resource" type="application/l10n" href="locale/locale.properties"/>
|
||||||
<!--#endif-->
|
<!--#endif-->
|
||||||
|
|
||||||
<!--#if !(FIREFOX || MOZCENTRAL || CHROME)-->
|
<!--#if !(FIREFOX || MOZCENTRAL || CHROME || MINIFIED)-->
|
||||||
<script type="text/javascript" src="compatibility.js"></script>
|
<script type="text/javascript" src="compatibility.js"></script>
|
||||||
<!--#endif-->
|
<!--#endif-->
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ limitations under the License.
|
|||||||
<script type="text/javascript">PDFJS.workerSrc = '../src/worker_loader.js';</script>
|
<script type="text/javascript">PDFJS.workerSrc = '../src/worker_loader.js';</script>
|
||||||
<!--#endif-->
|
<!--#endif-->
|
||||||
|
|
||||||
<!--#if GENERIC -->
|
<!--#if (GENERIC && !MINIFIED) -->
|
||||||
<!--#include viewer-snippet.html-->
|
<!--#include viewer-snippet.html-->
|
||||||
<!--#endif-->
|
<!--#endif-->
|
||||||
|
|
||||||
@ -79,8 +79,12 @@ limitations under the License.
|
|||||||
<script type="text/javascript" src="hand_tool.js"></script>
|
<script type="text/javascript" src="hand_tool.js"></script>
|
||||||
<!--#endif-->
|
<!--#endif-->
|
||||||
|
|
||||||
|
<!--#if !MINIFIED -->
|
||||||
<script type="text/javascript" src="debugger.js"></script>
|
<script type="text/javascript" src="debugger.js"></script>
|
||||||
<script type="text/javascript" src="viewer.js"></script>
|
<script type="text/javascript" src="viewer.js"></script>
|
||||||
|
<!--#else-->
|
||||||
|
<!--#include viewer-snippet-minified.html-->
|
||||||
|
<!--#endif-->
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user