Skip to content

Commit 18592d7

Browse files
committed
Fix #120
1 parent 2e75877 commit 18592d7

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

docs/PREPROCESSORS.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,13 @@ cssModules: {
4949
}
5050
}
5151
```
52+
53+
### Passing Through Other Files
54+
55+
When you configure an `intermediateOutputPath`, ember-css-modules will automatically pass through all files with stylesheet-like extensions for subsequent processors to be able to include. If you're relying on being able to reference data from other files in a downstream processing step, you may configure the extensions of files that should be passed on.
56+
57+
```js
58+
cssModules: {
59+
passthroughFileExtensions: ['json']
60+
}
61+
```

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ module.exports = {
9595
return this.project;
9696
},
9797

98+
getPassthroughFileExtensions() {
99+
return this.cssModulesOptions.passthroughFileExtensions || ['css', 'scss', 'sass', 'less', 'styl'];
100+
},
101+
98102
getScopedNameGenerator() {
99103
return this.cssModulesOptions.generateScopedName || require('./lib/generate-scoped-name');
100104
},

lib/output-styles-preprocessor.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const ensurePosixPath = require('ensure-posix-path');
55
const Concat = require('broccoli-concat');
66
const MergeTrees = require('broccoli-merge-trees');
77
const PostCSS = require('broccoli-postcss');
8+
const Funnel = require('broccoli-funnel');
89

910
module.exports = class OutputStylesPreprocessor {
1011
constructor(options) {
@@ -38,6 +39,10 @@ module.exports = class OutputStylesPreprocessor {
3839
// If an intermediate output path is specified, we need to pass through the full contents of the styles tree
3940
// and trust that a subsequent preprocessor will appropriately filter out everything else.
4041
if (this.owner.getIntermediateOutputPath()) {
42+
let passthroughExtensions = this.owner.getPassthroughFileExtensions();
43+
if (passthroughExtensions.length) {
44+
inputNode = new Funnel(inputNode, { include: passthroughExtensions.map(ext => `**/*.${ext}`) });
45+
}
4146
return new MergeTrees([inputNode, concat], { overwrite: true });
4247
} else {
4348
return concat;

0 commit comments

Comments
 (0)