-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[gatsby-plugin-less] Extend less-plugin with support for
modifyVars
(…
…#3801) * [gatsby-plugin-less] Extend less-plugin with support for `modifyVars` The less plugin did its job, but when I was going to use it with a library I experienced that it was lacking the ability to modify less-variables. This made it hard to customize less libraries. By letting the user provide a `options` in `gatsby-config.js`, the plugin can overwrite variables defined in the less stylesheet and hence makes it a breeze to customize libraries. The user has two options to include vars: either a object defined directly in the `gatsby-config.js` or define a file which exports an object that will be used as the options. * Update README.md
- Loading branch information
1 parent
e5993ce
commit d9a178c
Showing
5 changed files
with
225 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,50 @@ | ||
# gatsby-plugin-less | ||
|
||
Stub README | ||
Adds the ability to load and parse Less-flavored CSS. | ||
|
||
## Install | ||
|
||
`npm install --save gatsby-plugin-less` | ||
|
||
## How to use | ||
|
||
Add the plugin to your `gatsby-config.js`. | ||
|
||
```javascript | ||
plugins: [`gatsby-plugin-plugin-less`]; | ||
``` | ||
|
||
By default this plugin will compile `*.less` and `*.module.less` files. The plugin can also be used with `modifyVars` as it is explained [here](http://lesscss.org/usage/). By defining a javascript object you can overwrite less-variables. This can be useful when using a component library like [antd](https://ant.design/docs/react/introduce). | ||
|
||
```javascript | ||
plugins: [ | ||
{ | ||
resolve: `gatsby-plugin-less`, | ||
options: { | ||
theme: { | ||
'text-color': `#fff` | ||
}, | ||
}, | ||
}, | ||
]; | ||
``` | ||
|
||
Or you can specify a file which exports a object in the same form. | ||
|
||
```javascript | ||
plugins: [ | ||
{ | ||
resolve: `gatsby-plugin-less`, | ||
options: { | ||
theme: `./src/theme.js` | ||
}, | ||
}, | ||
]; | ||
``` | ||
|
||
In file `./src/theme.js`: | ||
```javascript | ||
module.exports = { | ||
'text-color': `#fff` | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
'text-color': `#fff`, | ||
} |