Created
October 10, 2014 15:57
-
-
Save ear/aa46c3cc92842035a91c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… | |
// hotfix sass sourcemaps | |
var appSassFiles = pickFiles('app', { | |
srcDir: '/styles', | |
destDir: '/assets/styles' | |
}); | |
var bootstrapSassFiles = pickFiles('bower_components/bootstrap-sass-official/assets/stylesheets', { | |
srcDir: 'bootstrap', | |
destDir: '/assets/styles/bower_components/bootstrap-sass-official/assets/stylesheets/bootstrap' | |
}); | |
var fontAwesomeSassFiles = pickFiles('bower_components/fontawesome', { | |
srcDir: 'scss', | |
destDir: '/assets/styles/bower_components/fontawesome/scss' | |
}); | |
var hotfixSassSourceMaps = require('./vendor/hotfix-sass-sourcemaps.js'); | |
module.exports = mergeTrees([ hotfixSassSourceMaps(app.toTree()), faFonts, appSassFiles, bootstrapSassFiles, fontAwesomeSassFiles]); | |
… |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Filter = require('broccoli-filter'); | |
/* | |
* fix sourceMappingURL=… | |
*/ | |
function SourceMapPathFixerFilter(inputTree) { | |
if (!(this instanceof SourceMapPathFixerFilter)) { | |
return new SourceMapPathFixerFilter(inputTree); | |
} | |
this.inputTree = inputTree; | |
} | |
SourceMapPathFixerFilter.prototype = Object.create(Filter.prototype); | |
SourceMapPathFixerFilter.prototype.constructor = SourceMapPathFixerFilter; | |
SourceMapPathFixerFilter.prototype.extensions = ['css']; | |
SourceMapPathFixerFilter.prototype.targetExtension = 'css'; | |
SourceMapPathFixerFilter.prototype.processString = function (str) { | |
return str.replace(/\/\*# sourceMappingURL=(.*)\/(.*\.css\.map) \*\//g, '/*# sourceMappingURL=/assets/$2 */'); | |
}; | |
/* | |
* fix .map source:[…paths…] | |
*/ | |
function SourceMapSourcesPathFixerFilter(inputTree) { | |
if (!(this instanceof SourceMapSourcesPathFixerFilter)) { | |
return new SourceMapSourcesPathFixerFilter(inputTree); | |
} | |
this.inputTree = inputTree; | |
} | |
SourceMapSourcesPathFixerFilter.prototype = Object.create(Filter.prototype); | |
SourceMapSourcesPathFixerFilter.prototype.constructor = SourceMapSourcesPathFixerFilter; | |
SourceMapSourcesPathFixerFilter.prototype.extensions = ['map']; | |
SourceMapSourcesPathFixerFilter.prototype.targetExtension = 'map'; | |
SourceMapSourcesPathFixerFilter.prototype.processString = function (str) { | |
var sourceMap = JSON.parse(str); | |
sourceMap.sources = sourceMap.sources.map(function (source) { | |
return "/assets/styles/" + source.replace(/^(\.\.\/)+/g, ''); | |
}); | |
return JSON.stringify(sourceMap, null, 2); | |
} | |
/* | |
* combined filter | |
*/ | |
function HotfixSassSourceMapsFilter (tree) { | |
return SourceMapSourcesPathFixerFilter(SourceMapPathFixerFilter(tree)); | |
} | |
module.exports = HotfixSassSourceMapsFilter; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment