You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+38Lines changed: 38 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -73,6 +73,22 @@ For example, the component given above in pod structure would look like this in
73
73
74
74
Similarly, if you were styling e.g. your application controller, you would mirror the template at `app/templates/application.hbs` and put your CSS at `app/styles/application.css`.
75
75
76
+
### Component Colocation in Octane Applications
77
+
78
+
In Octane apps, where component templates can be colocated with their backing class, your styles module for a component takes the same name as the backing class and template files:
In the example above, `hello-class` is rewritten internally to something like `_hello-class_1dr4n4` to ensure it doesn't conflict with a `hello-class` defined in some other module.
**Note**: by default, the import path for a styles module does _not_ include the `.css` (or equivalent) extension. However, if you set `includeExtensionInModulePath: true`, then you'd instead write:
Note that the extension is **always** included for styles modules that are part of an Octane "colocated" component, to avoid a conflict with the import path for the component itself.
167
+
144
168
### Applying Classes to a Component's Root Element
145
169
146
170
There is no root element, if you are using either of the following:
@@ -387,6 +411,20 @@ module.exports = {
387
411
};
388
412
```
389
413
414
+
### Extensions in Module Paths
415
+
416
+
When importing a CSS module's values from JS, or referencing it via `@value` or `composes:`, by default you do not include the `.css` extension in the import path. The exception to this rule is for modules that are part of an Octane-style colocated component, as the extension is the only thing to differentiate the styles module from the component module itself.
417
+
418
+
If you wish to enable this behavior for _all_ modules, you can set the `includeExtensionInModulePath` flag in your configuration:
419
+
420
+
```js
421
+
newEmberApp(defaults, {
422
+
cssModules: {
423
+
includeExtensionInModulePath:true,
424
+
},
425
+
});
426
+
```
427
+
390
428
### Scoped Name Generation
391
429
392
430
By default, ember-css-modules produces a unique scoped name for each class in a module by combining the original class name with a hash of the path of the containing module. You can override this behavior by passing a `generateScopedName` function in the configuration.
0 commit comments