-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove ember-css-modules #167
Conversation
6506c12
to
1e1e1e6
Compare
1be2016
to
aa2dc5e
Compare
aa2dc5e
to
2a2b2fd
Compare
* fix(docs): only process own styles as local * bugfix: Used includes (weakened assertion) to avoid false negatives --------- Co-authored-by: ijlee2 <ijlee2@users.noreply.github.com>
{ | ||
files: '*.css.d.ts', | ||
options: { | ||
quoteProps: 'preserve', | ||
}, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
module: { | ||
rules: [ | ||
{ | ||
exclude: /node_modules/, | ||
test: /\.css$/i, | ||
use: [ | ||
{ | ||
loader: 'postcss-loader', | ||
options: { | ||
sourceMap: !isProduction(), | ||
postcssOptions: { | ||
config: './postcss.config.js', | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For more options, including how to configure url-loader
, see https://github.com/evoactivity/ember-modern-css#webpack-configuration.
/* | ||
plugins.push( | ||
require('cssnano')({ | ||
preset: 'default', | ||
}) | ||
); | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@buschtoens found that cssnano
may not be needed anymore, because Embroider handles minifying CSS in production.
export default interface Registry | ||
extends EmberContainerQueryRegistry, | ||
EmbroiderCssModulesRegistry { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mode: (resourcePath) => { | ||
// The host app and active child addons are moved into a common | ||
// stable temp dir (`options.workspaceDir`), before the `css-loader` | ||
// processes them. | ||
// | ||
// We want to enable local mode only for our own host app. All other | ||
// addons should be loaded in global mode. | ||
const hostAppWorkspaceDir = `${options.workspaceDir}/${app.name}`; | ||
const isHostAppPath = resourcePath.includes(hostAppWorkspaceDir); | ||
|
||
return isHostAppPath ? 'local' : 'global'; | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found a couple of cases where mode
returns the incorrect value. Please see #188 for the bug fix.
Background
ember-css-modules
, which lets us localize styles, is not fully compatible with Embroider. Since July 2022, @evoactivity and the Ember community have looked into how else we can implement CSS modules.About a couple of weeks ago, I began working on
embroider-css-modules
, a set of tools and conventions to help people implement CSS modules. This pull request shows how people can migrate their apps.Notes
Commits 2 and 3 should be considered as one (1) step. I have them as separate to credit @buschtoens, who figured out how to more precisely define
css-loader
'smode()
.Commit 7 shows three (3) types of optimizations, which I hand-rolled in order to improve readability and show areas where
ember-codemod-remove-ember-css-modules
could improve on in the future.