Skip to content

Commit b932ee7

Browse files
committed
Addons default to the root app's generateScopedName config
1 parent 1ae7706 commit b932ee7

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,8 @@ new EmberApp(defaults, {
440440
});
441441
```
442442

443+
Note that addons may specify their own `generateScopedName` function, but otherwise they will fall back to using the one (if any) specified by the host application.
444+
443445
### Source Maps
444446

445447
Ember CLI allows you to [specify source map settings](https://ember-cli.com/user-guide/#source-maps) for your entire build process, and ember-css-modules will honor that configuration. For instance, to enable source maps in all environments for both JS and CSS files, you could put the following in your `ember-cli-build.js`:

packages/ember-css-modules/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,14 @@ module.exports = {
115115
},
116116

117117
getScopedNameGenerator() {
118-
return this.cssModulesOptions.generateScopedName || require('./lib/generate-scoped-name');
118+
if (!this._scopedNameGenerator) {
119+
let rootOptions = this._findRootApp().options.cssModules || {};
120+
this._scopedNameGenerator = this.cssModulesOptions.generateScopedName
121+
|| rootOptions.generateScopedName
122+
|| require('./lib/generate-scoped-name');
123+
}
124+
125+
return this._scopedNameGenerator;
119126
},
120127

121128
getModuleRelativePath(fullPath) {

0 commit comments

Comments
 (0)