Skip to content

Update docs #9

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

Merged
merged 4 commits into from
Oct 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 56 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ module.exports = {
use: [
"style-loader",
"@teamsupercell/typings-for-css-modules-loader",
"css-loader"
{
loader: "css-loader",
options: { modules: true }
}
]
}
]
Expand Down Expand Up @@ -59,7 +62,10 @@ module.exports = {
"// autogenerated by typings-for-css-modules-loader. \n// Please do not change this file!"
}
},
"css-loader"
{
loader: "css-loader",
options: { modules: true }
}
]
}
]
Expand All @@ -84,7 +90,10 @@ module.exports = {
formatter: "prettier"
}
},
"css-loader"
{
loader: "css-loader",
options: { modules: true }
}
]
}
]
Expand All @@ -110,7 +119,10 @@ module.exports = {
eol: "\r\n"
}
},
"css-loader"
{
loader: "css-loader",
options: { modules: true }
}
]
}
]
Expand Down Expand Up @@ -167,6 +179,46 @@ console.log(locals.someOtherClass);

![typed-css-modules](https://cloud.githubusercontent.com/assets/749171/16340497/c1cb6888-3a28-11e6-919b-f2f51a282bba.gif)

## Upgrade from v1:
- Update webpack config
- This package no longer replaces `css-loader`, but it has to be added alongside `css-loader`:
- `css-loader` is no longer a peer dependency due to the change above
- `css-loader` will need to be configured to output CSS Modules (e.g. `options: { modules: true; }`)
```diff
module.exports = {
module: {
rules: [
{
test: /\.css$/i,
use: [
"style-loader",
{
loader: "@teamsupercell/typings-for-css-modules-loader",
options: {
// pass all the options for `css-loader` to `css-loader`, eg.
- namedExport: true,
- modules: true
}
},
+ {
+ loader: "css-loader",
+ options: {
+ modules: true
+ }
+ },
]
}
]
}
};
```
- Ensure all the typescript files import styles as default
```diff
- import * as styles from './styles.css';
+ import styles from './styles.css';
```
- Add `allowSyntheticDefaultImports` TypeScript compiler option if there are type errors related to default imports

## Support

As the loader just acts as an intermediary it can handle all kind of css preprocessors (`sass`, `scss`, `stylus`, `less`, ...).
Expand Down
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
"typescript": "^3.5.3",
"webpack": "^4.39.1"
},
"peerDependencies": {
"css-loader": ">=0.28.11"
},
"optionalDependencies": {
"prettier": "*"
},
Expand Down