mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Merge pull request #10263 from meteor/fix-issue-10112-by-ignoring-inline-source-maps
Ignore inline source maps when minifying CSS files.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
Package.describe({
|
||||
name: 'standard-minifier-css',
|
||||
version: '1.5.0',
|
||||
version: '1.5.1',
|
||||
summary: 'Standard css minifier used with Meteor apps by default.',
|
||||
documentation: 'README.md'
|
||||
});
|
||||
|
||||
@@ -51,6 +51,11 @@ var hashFiles = Profile("hashFiles", function (files) {
|
||||
return hash.digest("hex");
|
||||
});
|
||||
|
||||
function disableSourceMappingURLs(css) {
|
||||
return css.replace(/# sourceMappingURL=/g,
|
||||
"# sourceMappingURL_DISABLED=");
|
||||
}
|
||||
|
||||
// Lints CSS files and merges them into one file, fixing up source maps and
|
||||
// pulling any @import directives up to the top since the CSS spec does not
|
||||
// allow them to appear in the middle of a file.
|
||||
@@ -69,7 +74,8 @@ var mergeCss = Profile("mergeCss", function (css) {
|
||||
originals[filename] = file;
|
||||
try {
|
||||
var parseOptions = { source: filename, position: true };
|
||||
var ast = CssTools.parseCss(file.getContentsAsString(), parseOptions);
|
||||
var css = disableSourceMappingURLs(file.getContentsAsString());
|
||||
var ast = CssTools.parseCss(css, parseOptions);
|
||||
ast.filename = filename;
|
||||
} catch (e) {
|
||||
if (e.reason) {
|
||||
@@ -114,7 +120,8 @@ var mergeCss = Profile("mergeCss", function (css) {
|
||||
// Add the contents of the input files to the source map of the new file
|
||||
stringifiedCss.map.sourcesContent =
|
||||
stringifiedCss.map.sources.map(function (filename) {
|
||||
return originals[filename].getContentsAsString();
|
||||
const file = originals[filename] || null;
|
||||
return file && file.getContentsAsString();
|
||||
});
|
||||
|
||||
// Compose the concatenated file's source map with source maps from the
|
||||
|
||||
Reference in New Issue
Block a user