Skip to content

Commit

Permalink
feat(gatsby-plugin-sass): Add ability to override sassRuleTest and sa…
Browse files Browse the repository at this point in the history
…ssRuleModulesTest (#16494)

* Add a configuration for sass plugin file regexes

Add 2 new options for gatsby-sass-plugin
- `sassRuleTest` to configure regex for sass files.
- `sassRuleModulesTest` to configure regex for css modules files.

Refer #15879 for motivation
behind this addition.

* Update README

with guide to override file regex for sass and css modules.

* make string regex

* fix snapshot
  • Loading branch information
tkbky authored and GatsbyJS Bot committed Aug 9, 2019
1 parent bd1a8aa commit df209d9
Show file tree
Hide file tree
Showing 4 changed files with 423 additions and 3 deletions.
19 changes: 19 additions & 0 deletions packages/gatsby-plugin-sass/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,25 @@ plugins: [
Using CSS Modules requires no additional configuration. Simply prepend `.module` to the extension. For example: `App.scss` -> `App.module.scss`.
Any file with the `module` extension will use CSS Modules.

## SASS & CSS Modules file Regexes

To override the file regex for SASS or CSS modules,

```javascript
// in gatsby-config.js
plugins: [
{
resolve: `gatsby-plugin-sass`,
options: {
// Override the file regex for SASS
sassRuleTest: /\.global\.s(a|c)ss$/,
// Override the file regex for CSS modules
sassRuleModulesTest: /\.global\.s(a|c)ss$/,
},
},
]
```

### PostCSS plugins

PostCSS is also included to handle some default optimizations like autoprefixing
Expand Down
Loading

0 comments on commit df209d9

Please sign in to comment.