diff --git a/packages/standard-minifier-css/package.js b/packages/standard-minifier-css/package.js index 5dde075548..d9ea6588f0 100644 --- a/packages/standard-minifier-css/package.js +++ b/packages/standard-minifier-css/package.js @@ -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' }); diff --git a/packages/standard-minifier-css/plugin/minify-css.js b/packages/standard-minifier-css/plugin/minify-css.js index bef5274b94..da99c0cc1c 100644 --- a/packages/standard-minifier-css/plugin/minify-css.js +++ b/packages/standard-minifier-css/plugin/minify-css.js @@ -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