Skip to content

Commit 992042f

Browse files
wardpeetLekoArts
andauthored
update migration guide for commonjs (#30267)
Co-authored-by: Lennart <[email protected]>
1 parent ecd4e4e commit 992042f

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

docs/docs/reference/release-notes/migrating-from-v2-to-v3.md

+24-1
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,30 @@ const Box = ({ children }) => (
367367
export default Box
368368
```
369369
370-
You can also still import all styles using the `import * as styles` syntax e.g. `import * as styles from './mystyles.module.css'`. However, this won't allow webpack to treeshake your styles so we discourage you from using this syntax.
370+
You can also import all styles using the `import * as styles` syntax e.g. `import * as styles from './mystyles.module.css'`. However, this won't allow webpack to treeshake your styles so we discourage you from using this syntax.
371+
372+
Migrating all your CSS could be painful or you're relying on third-party packages that require you to use CommonJS. You can work around this issue for Sass, Less, Stylus & regular CSS modules using respective plugins. If you're using regular CSS modules, please install [gatsby-plugin-postcss](https://www.gatsbyjs.com/plugins/gatsby-plugin-postcss/) to override the defaults.
373+
374+
This example covers Sass. The other plugins share the same `cssLoaderOptions` property.
375+
376+
```diff:title=gatsby-config.js
377+
module.exports = {
378+
plugins: [
379+
- `gatsby-plugin-sass`,
380+
+ {
381+
+ resolve: `gatsby-plugin-sass`,
382+
+ options: {
383+
+ cssLoaderOptions: {
384+
+ esModule: false,
385+
+ modules: {
386+
+ namedExport: false,
387+
+ },
388+
+ },
389+
+ },
390+
+ }
391+
]
392+
}
393+
```
371394
372395
### File assets (fonts, pdfs, ...) are imported as ES Modules
373396

0 commit comments

Comments
 (0)