Adds css import preprocessing
This commit is contained in:
parent
f5d416cfdf
commit
5b93cc102c
22
external/builder/builder.js
vendored
22
external/builder/builder.js
vendored
@ -123,6 +123,15 @@ function preprocessCSS(mode, source, destination) {
|
|||||||
deprecatedInMozcentral.test(line));
|
deprecatedInMozcentral.test(line));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function expandImports(content, baseUrl) {
|
||||||
|
return content.replace(/^\s*@import\s+url\(([^\)]+)\);\s*$/gm,
|
||||||
|
function(all, url) {
|
||||||
|
var file = path.join(path.dirname(baseUrl), url);
|
||||||
|
var imported = fs.readFileSync(file, 'utf8').toString();
|
||||||
|
return expandImports(imported, file);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function removePrefixed(content, hasPrefixedFilter) {
|
function removePrefixed(content, hasPrefixedFilter) {
|
||||||
var lines = content.split(/\r?\n/g);
|
var lines = content.split(/\r?\n/g);
|
||||||
var i = 0;
|
var i = 0;
|
||||||
@ -168,14 +177,17 @@ function preprocessCSS(mode, source, destination) {
|
|||||||
return lines.join('\n');
|
return lines.join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode !== 'firefox' && mode !== 'mozcentral') {
|
if (!mode) {
|
||||||
throw new Error('Invalid CSS preprocessor mode');
|
throw new Error('Invalid CSS preprocessor mode');
|
||||||
}
|
}
|
||||||
|
|
||||||
var content = fs.readFileSync(source, 'utf8');
|
var content = fs.readFileSync(source, 'utf8').toString();
|
||||||
var out = removePrefixed(content,
|
content = expandImports(content, source);
|
||||||
mode === 'mozcentral' ? hasPrefixedMozcentral : hasPrefixedFirefox);
|
if (mode === 'mozcentral' || mode === 'firefox') {
|
||||||
fs.writeFileSync(destination, out);
|
content = removePrefixed(content, mode === 'mozcentral' ?
|
||||||
|
hasPrefixedMozcentral : hasPrefixedFirefox);
|
||||||
|
}
|
||||||
|
fs.writeFileSync(destination, content);
|
||||||
}
|
}
|
||||||
exports.preprocessCSS = preprocessCSS;
|
exports.preprocessCSS = preprocessCSS;
|
||||||
|
|
||||||
|
31
make.js
31
make.js
@ -126,7 +126,6 @@ target.generic = function() {
|
|||||||
[COMMON_WEB_FILES, GENERIC_DIR + '/web'],
|
[COMMON_WEB_FILES, GENERIC_DIR + '/web'],
|
||||||
['LICENSE', GENERIC_DIR],
|
['LICENSE', GENERIC_DIR],
|
||||||
['external/webL10n/l10n.js', GENERIC_DIR + '/web'],
|
['external/webL10n/l10n.js', GENERIC_DIR + '/web'],
|
||||||
['web/viewer.css', GENERIC_DIR + '/web'],
|
|
||||||
['web/compatibility.js', GENERIC_DIR + '/web'],
|
['web/compatibility.js', GENERIC_DIR + '/web'],
|
||||||
['web/compressed.tracemonkey-pldi-09.pdf', GENERIC_DIR + '/web'],
|
['web/compressed.tracemonkey-pldi-09.pdf', GENERIC_DIR + '/web'],
|
||||||
['external/bcmaps/*', GENERIC_DIR + '/web/cmaps/'],
|
['external/bcmaps/*', GENERIC_DIR + '/web/cmaps/'],
|
||||||
@ -135,11 +134,16 @@ target.generic = function() {
|
|||||||
preprocess: [
|
preprocess: [
|
||||||
[BUILD_TARGETS, GENERIC_DIR + BUILD_DIR],
|
[BUILD_TARGETS, GENERIC_DIR + BUILD_DIR],
|
||||||
[COMMON_WEB_FILES_PREPROCESS, GENERIC_DIR + '/web']
|
[COMMON_WEB_FILES_PREPROCESS, GENERIC_DIR + '/web']
|
||||||
|
],
|
||||||
|
preprocessCSS: [
|
||||||
|
['generic', 'web/viewer.css',
|
||||||
|
GENERIC_DIR + '/web/viewer.css']
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
builder.build(setup);
|
builder.build(setup);
|
||||||
|
|
||||||
cleanupJSSource(GENERIC_DIR + '/web/viewer.js');
|
cleanupJSSource(GENERIC_DIR + '/web/viewer.js');
|
||||||
|
cleanupCSSSource(GENERIC_DIR + '/web/viewer.css');
|
||||||
};
|
};
|
||||||
|
|
||||||
target.jsdoc = function() {
|
target.jsdoc = function() {
|
||||||
@ -557,6 +561,16 @@ function cleanupJSSource(file) {
|
|||||||
content.to(file);
|
content.to(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function cleanupCSSSource(file) {
|
||||||
|
var content = cat(file);
|
||||||
|
|
||||||
|
// Strip out all license headers in the middle.
|
||||||
|
var reg = /\n\/\* Copyright(.|\n)*?Mozilla Foundation(.|\n)*?\*\//g;
|
||||||
|
content = content.replace(reg, '');
|
||||||
|
|
||||||
|
content.to(file);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// make minified
|
// make minified
|
||||||
// Builds the minified production viewer that should be compatible with most
|
// Builds the minified production viewer that should be compatible with most
|
||||||
@ -588,7 +602,6 @@ target.minified = function() {
|
|||||||
defines: defines,
|
defines: defines,
|
||||||
copy: [
|
copy: [
|
||||||
[COMMON_WEB_FILES, MINIFIED_DIR + '/web'],
|
[COMMON_WEB_FILES, MINIFIED_DIR + '/web'],
|
||||||
['web/viewer.css', MINIFIED_DIR + '/web'],
|
|
||||||
['web/compressed.tracemonkey-pldi-09.pdf', MINIFIED_DIR + '/web'],
|
['web/compressed.tracemonkey-pldi-09.pdf', MINIFIED_DIR + '/web'],
|
||||||
['external/bcmaps/*', MINIFIED_DIR + '/web/cmaps'],
|
['external/bcmaps/*', MINIFIED_DIR + '/web/cmaps'],
|
||||||
['web/locale', MINIFIED_DIR + '/web']
|
['web/locale', MINIFIED_DIR + '/web']
|
||||||
@ -596,10 +609,16 @@ target.minified = function() {
|
|||||||
preprocess: [
|
preprocess: [
|
||||||
[BUILD_TARGETS, MINIFIED_DIR + BUILD_DIR],
|
[BUILD_TARGETS, MINIFIED_DIR + BUILD_DIR],
|
||||||
[COMMON_WEB_FILES_PREPROCESS, MINIFIED_DIR + '/web']
|
[COMMON_WEB_FILES_PREPROCESS, MINIFIED_DIR + '/web']
|
||||||
|
],
|
||||||
|
preprocessCSS: [
|
||||||
|
['minified', 'web/viewer.css',
|
||||||
|
MINIFIED_DIR + '/web/viewer.css']
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
builder.build(setup);
|
builder.build(setup);
|
||||||
|
|
||||||
|
cleanupCSSSource(MINIFIED_DIR + '/web/viewer.css');
|
||||||
|
|
||||||
var viewerFiles = [
|
var viewerFiles = [
|
||||||
'web/compatibility.js',
|
'web/compatibility.js',
|
||||||
'external/webL10n/l10n.js',
|
'external/webL10n/l10n.js',
|
||||||
@ -750,6 +769,7 @@ target.firefox = function() {
|
|||||||
cleanupJSSource(FIREFOX_BUILD_CONTENT_DIR + '/web/viewer.js');
|
cleanupJSSource(FIREFOX_BUILD_CONTENT_DIR + '/web/viewer.js');
|
||||||
cleanupJSSource(FIREFOX_BUILD_DIR + 'bootstrap.js');
|
cleanupJSSource(FIREFOX_BUILD_DIR + 'bootstrap.js');
|
||||||
cleanupJSSource(FIREFOX_BUILD_CONTENT_DIR + 'PdfjsChromeUtils.jsm');
|
cleanupJSSource(FIREFOX_BUILD_CONTENT_DIR + 'PdfjsChromeUtils.jsm');
|
||||||
|
cleanupCSSSource(FIREFOX_BUILD_CONTENT_DIR + '/web/viewer.css');
|
||||||
|
|
||||||
// Remove '.DS_Store' and other hidden files
|
// Remove '.DS_Store' and other hidden files
|
||||||
find(FIREFOX_BUILD_DIR).forEach(function(file) {
|
find(FIREFOX_BUILD_DIR).forEach(function(file) {
|
||||||
@ -872,6 +892,7 @@ target.mozcentral = function() {
|
|||||||
cleanupJSSource(MOZCENTRAL_CONTENT_DIR + '/web/viewer.js');
|
cleanupJSSource(MOZCENTRAL_CONTENT_DIR + '/web/viewer.js');
|
||||||
cleanupJSSource(MOZCENTRAL_CONTENT_DIR + '/PdfJs.jsm');
|
cleanupJSSource(MOZCENTRAL_CONTENT_DIR + '/PdfJs.jsm');
|
||||||
cleanupJSSource(MOZCENTRAL_CONTENT_DIR + '/PdfjsChromeUtils.jsm');
|
cleanupJSSource(MOZCENTRAL_CONTENT_DIR + '/PdfjsChromeUtils.jsm');
|
||||||
|
cleanupCSSSource(MOZCENTRAL_CONTENT_DIR + '/web/viewer.css');
|
||||||
|
|
||||||
// Remove '.DS_Store' and other hidden files
|
// Remove '.DS_Store' and other hidden files
|
||||||
find(MOZCENTRAL_DIR).forEach(function(file) {
|
find(MOZCENTRAL_DIR).forEach(function(file) {
|
||||||
@ -982,18 +1003,22 @@ target.chromium = function() {
|
|||||||
CHROME_BUILD_DIR],
|
CHROME_BUILD_DIR],
|
||||||
['extensions/chromium/pageAction/*.*', CHROME_BUILD_DIR + '/pageAction'],
|
['extensions/chromium/pageAction/*.*', CHROME_BUILD_DIR + '/pageAction'],
|
||||||
['external/webL10n/l10n.js', CHROME_BUILD_CONTENT_DIR + '/web'],
|
['external/webL10n/l10n.js', CHROME_BUILD_CONTENT_DIR + '/web'],
|
||||||
['web/viewer.css', CHROME_BUILD_CONTENT_DIR + '/web'],
|
|
||||||
['external/bcmaps/*', CHROME_BUILD_CONTENT_DIR + '/web/cmaps'],
|
['external/bcmaps/*', CHROME_BUILD_CONTENT_DIR + '/web/cmaps'],
|
||||||
['web/locale', CHROME_BUILD_CONTENT_DIR + '/web']
|
['web/locale', CHROME_BUILD_CONTENT_DIR + '/web']
|
||||||
],
|
],
|
||||||
preprocess: [
|
preprocess: [
|
||||||
[BUILD_TARGETS, CHROME_BUILD_CONTENT_DIR + BUILD_DIR],
|
[BUILD_TARGETS, CHROME_BUILD_CONTENT_DIR + BUILD_DIR],
|
||||||
[COMMON_WEB_FILES_PREPROCESS, CHROME_BUILD_CONTENT_DIR + '/web']
|
[COMMON_WEB_FILES_PREPROCESS, CHROME_BUILD_CONTENT_DIR + '/web']
|
||||||
|
],
|
||||||
|
preprocessCSS: [
|
||||||
|
['chrome', 'web/viewer.css',
|
||||||
|
CHROME_BUILD_CONTENT_DIR + '/web/viewer.css']
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
builder.build(setup);
|
builder.build(setup);
|
||||||
|
|
||||||
cleanupJSSource(CHROME_BUILD_CONTENT_DIR + '/web/viewer.js');
|
cleanupJSSource(CHROME_BUILD_CONTENT_DIR + '/web/viewer.js');
|
||||||
|
cleanupCSSSource(CHROME_BUILD_CONTENT_DIR + '/web/viewer.css');
|
||||||
|
|
||||||
// Update the build version number
|
// Update the build version number
|
||||||
sed('-i', /PDFJSSCRIPT_VERSION/, VERSION,
|
sed('-i', /PDFJSSCRIPT_VERSION/, VERSION,
|
||||||
|
Loading…
Reference in New Issue
Block a user