Skip to content

Commit 9a58b36

Browse files
lanepartonLekoArts
andauthored
fix(gatsby-plugin-sass): Add support for additionalData option (#36086)
Co-authored-by: Lennart <lekoarts@gmail.com>
1 parent 80d219a commit 9a58b36

File tree

4 files changed

+83
-0
lines changed

4 files changed

+83
-0
lines changed

packages/gatsby-plugin-sass/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,23 @@ plugins: [
6464
]
6565
```
6666

67+
### additionalData
68+
69+
Prepends Sass code before the actual entry file. In this case, the `sass-loader` will not override the data option but just prepend the entry's content. You might use this to prepend things like environmental variables (as Sass variables) or even prepend a global Sass import to be used in other Sass files (functions, mixins, variables, etc.).
70+
71+
See [webpack's sass-loader documentation](https://webpack.js.org/loaders/sass-loader/#additionaldata) for reference.
72+
73+
```javascript:title=gatsby-config.js
74+
plugins: [
75+
{
76+
resolve: `gatsby-plugin-sass`,
77+
options: {
78+
additionalData: "$env: " + process.env.NODE_ENV + ";",
79+
},
80+
},
81+
]
82+
```
83+
6784
### Alternative Sass Implementations
6885

6986
By default, the Dart implementation of Sass (`sass`) is used. To use the implementation written in Node (`node-sass`), you can install `node-sass` instead of `sass` and pass it into the options as the implementation:

0 commit comments

Comments
 (0)