mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-10 02:05:37 +02:00
Moves dist and minifiedpost tragets from make.js.
This commit is contained in:
parent
5ad3611cc4
commit
1d30cea914
2 changed files with 150 additions and 153 deletions
150
gulpfile.js
150
gulpfile.js
|
@ -52,12 +52,16 @@ var FIREFOX_BUILD_DIR = BUILD_DIR + 'firefox/';
|
|||
var CHROME_BUILD_DIR = BUILD_DIR + 'chromium/';
|
||||
var JSDOC_BUILD_DIR = BUILD_DIR + 'jsdoc/';
|
||||
var GH_PAGES_DIR = BUILD_DIR + 'gh-pages/';
|
||||
var SRC_DIR = 'src/';
|
||||
var LIB_DIR = BUILD_DIR + 'lib/';
|
||||
var DIST_DIR = BUILD_DIR + 'dist/';
|
||||
var COMMON_WEB_FILES = [
|
||||
'web/images/*.{png,svg,gif,cur}',
|
||||
'web/debugger.js'
|
||||
];
|
||||
|
||||
var REPO = 'git@github.com:mozilla/pdf.js.git';
|
||||
var DIST_REPO_URL = 'https://github.com/mozilla/pdfjs-dist';
|
||||
|
||||
var builder = require('./external/builder/builder.js');
|
||||
|
||||
|
@ -683,10 +687,42 @@ gulp.task('minified-pre', ['buildnumber', 'locale'], function () {
|
|||
]);
|
||||
});
|
||||
|
||||
gulp.task('minified', ['minified-pre'], function (done) {
|
||||
runSequence('minifiedpost', done);
|
||||
gulp.task('minified-post', ['minified-pre'], function () {
|
||||
var viewerFiles = [
|
||||
'external/webL10n/l10n.js',
|
||||
MINIFIED_DIR + BUILD_DIR + 'pdf.js',
|
||||
MINIFIED_DIR + '/web/viewer.js'
|
||||
];
|
||||
|
||||
console.log();
|
||||
console.log('### Minifying js files');
|
||||
|
||||
var UglifyJS = require('uglify-js');
|
||||
// V8 chokes on very long sequences. Works around that.
|
||||
var optsForHugeFile = {compress: {sequences: false}};
|
||||
|
||||
UglifyJS.minify(viewerFiles).code
|
||||
.to(MINIFIED_DIR + '/web/pdf.viewer.js');
|
||||
UglifyJS.minify(MINIFIED_DIR + '/build/pdf.js').code
|
||||
.to(MINIFIED_DIR + '/build/pdf.min.js');
|
||||
UglifyJS.minify(MINIFIED_DIR + '/build/pdf.worker.js', optsForHugeFile).code
|
||||
.to(MINIFIED_DIR + '/build/pdf.worker.min.js');
|
||||
|
||||
console.log();
|
||||
console.log('### Cleaning js files');
|
||||
|
||||
fs.unlinkSync(MINIFIED_DIR + '/web/viewer.js');
|
||||
fs.unlinkSync(MINIFIED_DIR + '/web/debugger.js');
|
||||
fs.unlinkSync(MINIFIED_DIR + '/build/pdf.js');
|
||||
fs.unlinkSync(MINIFIED_DIR + '/build/pdf.worker.js');
|
||||
fs.renameSync(MINIFIED_DIR + '/build/pdf.min.js',
|
||||
MINIFIED_DIR + '/build/pdf.js');
|
||||
fs.renameSync(MINIFIED_DIR + '/build/pdf.worker.min.js',
|
||||
MINIFIED_DIR + '/build/pdf.worker.js');
|
||||
});
|
||||
|
||||
gulp.task('minified', ['minified-post']);
|
||||
|
||||
gulp.task('firefox-pre', ['buildnumber', 'locale'], function () {
|
||||
console.log();
|
||||
console.log('### Building Firefox extension');
|
||||
|
@ -1229,6 +1265,116 @@ gulp.task('gh-pages-git', ['gh-pages-prepare', 'wintersmith'], function () {
|
|||
|
||||
gulp.task('web', ['gh-pages-prepare', 'wintersmith', 'gh-pages-git']);
|
||||
|
||||
gulp.task('dist-repo-prepare', ['dist-pre'], function () {
|
||||
var VERSION = getVersionJSON().version;
|
||||
|
||||
console.log();
|
||||
console.log('### Cloning baseline distribution');
|
||||
|
||||
rimraf.sync(DIST_DIR);
|
||||
mkdirp.sync(DIST_DIR);
|
||||
spawnSync('git', ['clone', '--depth', '1', DIST_REPO_URL, DIST_DIR]);
|
||||
|
||||
console.log();
|
||||
console.log('### Overwriting all files');
|
||||
rimraf.sync(path.join(DIST_DIR, '*'));
|
||||
|
||||
// Rebuilding manifests
|
||||
var DIST_NAME = 'pdfjs-dist';
|
||||
var DIST_DESCRIPTION = 'Generic build of Mozilla\'s PDF.js library.';
|
||||
var DIST_KEYWORDS = ['Mozilla', 'pdf', 'pdf.js'];
|
||||
var DIST_HOMEPAGE = 'http://mozilla.github.io/pdf.js/';
|
||||
var DIST_BUGS_URL = 'https://github.com/mozilla/pdf.js/issues';
|
||||
var DIST_LICENSE = 'Apache-2.0';
|
||||
var npmManifest = {
|
||||
name: DIST_NAME,
|
||||
version: VERSION,
|
||||
main: 'build/pdf.js',
|
||||
description: DIST_DESCRIPTION,
|
||||
keywords: DIST_KEYWORDS,
|
||||
homepage: DIST_HOMEPAGE,
|
||||
bugs: DIST_BUGS_URL,
|
||||
license: DIST_LICENSE,
|
||||
dependencies: {
|
||||
'node-ensure': '^0.0.0', // shim for node for require.ensure
|
||||
'worker-loader': '^0.8.0', // used in external/dist/webpack.json
|
||||
},
|
||||
browser: {
|
||||
'node-ensure': false
|
||||
},
|
||||
format: 'amd', // to not allow system.js to choose 'cjs'
|
||||
repository: {
|
||||
type: 'git',
|
||||
url: DIST_REPO_URL
|
||||
},
|
||||
};
|
||||
var packageJsonSrc =
|
||||
createStringSource('package.json', JSON.stringify(npmManifest, null, 2));
|
||||
var bowerManifest = {
|
||||
name: DIST_NAME,
|
||||
version: VERSION,
|
||||
main: [
|
||||
'build/pdf.js',
|
||||
'build/pdf.worker.js',
|
||||
],
|
||||
ignore: [],
|
||||
keywords: DIST_KEYWORDS,
|
||||
};
|
||||
var bowerJsonSrc =
|
||||
createStringSource('bower.json', JSON.stringify(bowerManifest, null, 2));
|
||||
|
||||
return merge([
|
||||
packageJsonSrc.pipe(gulp.dest(DIST_DIR)),
|
||||
bowerJsonSrc.pipe(gulp.dest(DIST_DIR)),
|
||||
vinyl.src('external/dist/**/*',
|
||||
{base: 'external/dist', stripBOM: false})
|
||||
.pipe(gulp.dest(DIST_DIR)),
|
||||
gulp.src(GENERIC_DIR + 'LICENSE')
|
||||
.pipe(gulp.dest(DIST_DIR)),
|
||||
gulp.src(GENERIC_DIR + 'web/cmaps/**/*',
|
||||
{base: GENERIC_DIR + 'web'})
|
||||
.pipe(gulp.dest(DIST_DIR)),
|
||||
gulp.src([
|
||||
GENERIC_DIR + 'build/pdf.js',
|
||||
GENERIC_DIR + 'build/pdf.worker.js',
|
||||
SINGLE_FILE_DIR + 'build/pdf.combined.js',
|
||||
SRC_DIR + 'pdf.worker.entry.js',
|
||||
]).pipe(gulp.dest(DIST_DIR + 'build/')),
|
||||
gulp.src(MINIFIED_DIR + 'build/pdf.js')
|
||||
.pipe(rename('pdf.min.js'))
|
||||
.pipe(gulp.dest(DIST_DIR + 'build/')),
|
||||
gulp.src(MINIFIED_DIR + 'build/pdf.worker.js')
|
||||
.pipe(rename('pdf.worker.min.js'))
|
||||
.pipe(gulp.dest(DIST_DIR + 'build/')),
|
||||
gulp.src(COMPONENTS_DIR + '**/*', {base: COMPONENTS_DIR})
|
||||
.pipe(gulp.dest(DIST_DIR + 'web/')),
|
||||
gulp.src(LIB_DIR + '**/*', {base: LIB_DIR})
|
||||
.pipe(gulp.dest(DIST_DIR + 'lib/')),
|
||||
]);
|
||||
});
|
||||
|
||||
gulp.task('dist-repo-git', ['dist-repo-prepare'], function () {
|
||||
var VERSION = getVersionJSON().version;
|
||||
|
||||
console.log();
|
||||
console.log('### Committing changes');
|
||||
|
||||
var reason = process.env['PDFJS_UPDATE_REASON'];
|
||||
var message = 'PDF.js version ' + VERSION + (reason ? ' - ' + reason : '');
|
||||
spawnSync('git', ['add', '*'], {cwd: DIST_DIR});
|
||||
spawnSync('git', ['commit', '-am', message], {cwd: DIST_DIR});
|
||||
spawnSync('git', ['tag', '-a', 'v' + VERSION, '-m', message],
|
||||
{cwd: DIST_DIR});
|
||||
|
||||
console.log();
|
||||
console.log('Done. Push with');
|
||||
console.log(' cd ' + DIST_DIR + '; ' +
|
||||
'git push --tags ' + DIST_REPO_URL + ' master');
|
||||
console.log();
|
||||
});
|
||||
|
||||
gulp.task('dist', ['dist-repo-git']);
|
||||
|
||||
// Getting all shelljs registered tasks and register them with gulp
|
||||
require('./make.js');
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue