broccoli-css-modules
Advanced tools
Comparing version 0.5.1 to 0.5.2
22
index.js
@@ -38,2 +38,4 @@ 'use strict'; | ||
this.formatCSS = options.formatCSS; | ||
this.enableSourceMaps = options.enableSourceMaps; | ||
this.sourceMapBaseDir = options.sourceMapBaseDir; | ||
this.postcssOptions = options.postcssOptions || {}; | ||
@@ -102,2 +104,4 @@ this.virtualModules = options.virtualModules || Object.create(null); | ||
return this.formatCSS(injectableSource, modulePath); | ||
} else if (this.enableSourceMaps) { | ||
return injectableSource; | ||
} else { | ||
@@ -145,3 +149,7 @@ return '/* styles for ' + modulePath + ' */\n' + injectableSource; | ||
CSSModules.prototype.load = function(content, dependency) { | ||
var options = this.processorOptions({ from: dependency.toString() }); | ||
var options = this.processorOptions({ | ||
from: dependency.toString(), | ||
map: this.sourceMapOptions(dependency) | ||
}); | ||
var processor = postcss([] | ||
@@ -161,2 +169,14 @@ .concat(this.plugins.before) | ||
CSSModules.prototype.sourceMapOptions = function(dependency) { | ||
if (!this.enableSourceMaps) return; | ||
var dir = this.sourceMapBaseDir ? ('/' + ensurePosixPath(this.sourceMapBaseDir)) : ''; | ||
return { | ||
inline: true, | ||
sourcesContent: true, | ||
annotation: this.posixInputPath() + dir + '/output.map' | ||
}; | ||
}; | ||
CSSModules.prototype.loaderPlugins = function(dependency) { | ||
@@ -163,0 +183,0 @@ return [ |
{ | ||
"name": "broccoli-css-modules", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"description": "A broccoli plugin for compiling CSS modules", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -76,2 +76,8 @@ # broccoli-css-modules [![Build Status](https://travis-ci.org/salsify/broccoli-css-modules.svg?branch=master)](https://travis-ci.org/salsify/broccoli-css-modules) [![Window Build Status](https://ci.appveyor.com/api/projects/status/github/salsify/broccoli-css-modules?svg=true)](https://ci.appveyor.com/project/dfreeman97827/broccoli-css-modules) | ||
#### `enableSourceMaps` | ||
Whether inline source maps should be generated for the transformed module CSS. | ||
#### `sourceMapBaseDir` | ||
The base directory relative to which paths in source maps should be encoded. Defaults to the base of the input tree. | ||
##### `postcssOptions` | ||
@@ -78,0 +84,0 @@ A hash of options that will be passed directly through to the PostCSS processor. This allows the use of e.g. custom syntax in the processed files. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15731
242
96