From 74a697c332dc3b04fd1b312753953e93fa6ea098 Mon Sep 17 00:00:00 2001 From: David Glasser Date: Fri, 15 May 2015 14:12:54 -0700 Subject: [PATCH] Transition *.css to compiler plugins Note that we will need to execute our plan to bump the isopack/unibuild formats and do careful backwards compatibility in order for published packages containing these css sources to still be usable by existing versions of Meteor. (This also will include bumping compiler.BUILT_BY.) --- packages/meteor/plugin/basic-file-types.js | 26 +++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/packages/meteor/plugin/basic-file-types.js b/packages/meteor/plugin/basic-file-types.js index 39d78e2b35..cc000ff862 100644 --- a/packages/meteor/plugin/basic-file-types.js +++ b/packages/meteor/plugin/basic-file-types.js @@ -2,9 +2,25 @@ we can't exactly define the *.js source file handler in a *.js source file. */ -Plugin.registerSourceHandler("css", {archMatching: 'web'}, function (compileStep) { - compileStep.addStylesheet({ - data: compileStep.read().toString('utf8'), - path: compileStep.inputPath - }); +// NOTE: It's only OK for *this* package to call this function directly, because +// otherwise we'd end up with a circular dependency between meteor and +// compiler-plugin. The issue we're trying to avoid by requiring an explicit +// dependency on compiler-plugin doesn't matter because css has some +// backwards-compatibility special-casing in the tool. +Plugin._doNotCallThisDirectly_registerCompiler({ + extensions: ['css'], + archMatching: 'web' +}, function () { + return new CssCompiler; }); + +var CssCompiler = function () { +}; +CssCompiler.prototype.processFilesForTarget = function (inputFiles) { + inputFiles.forEach(function (inputFile) { + inputFile.addStylesheet({ + data: inputFile.getContentsAsString(), + path: inputFile.getPathInPackage() + }); + }); +};