@upline-io/gatsby-plugin-less-typescript
v3.2.2
Published
Gatsby plugin to add support for using Less with Typescript
Downloads
2
Maintainers
Readme
gatsby-plugin-less-typescript
Provides drop-in support for Less stylesheets with Typescript
Install
npm install --save less gatsby-plugin-less-typescript
How to use
- Include the plugin in your
gatsby-config.js
file. - Write your stylesheets in Less and require or import them as normal.
// in gatsby-config.js
plugins: [`gatsby-plugin-less-typescript`]
If you need to pass options to Less use the plugins options; see less-loader for all available options.
// in gatsby-config.js
plugins: [
{
resolve: `gatsby-plugin-less-typescript`,
options: {
strictMath: true,
},
},
]
If you need to override the default options passed into css-loader
// in gatsby-config.js
plugins: [
{
resolve: `gatsby-plugin-less-typescript`,
options: {
cssLoaderOptions: {
camelCase: false,
},
},
},
]
If you need to provide Less plugins, normally you would provide a plugins
in the Less options, but this option attribute is already used by Gatsby. It has been remapped to lessPlugins
// in gatsby-config.js
plugins: [
{
resolve: `gatsby-plugin-less-typescript`,
options: {
lessPlugins: [MyLessPlugin],
},
},
]
With CSS Modules
Using CSS modules requires no additional configuration. Simply prepend .module
to the extension. For example: App.less
-> App.module.less
.
Any file with the module
extension will use CSS modules.
PostCSS plugins
PostCSS is also included to handle some default optimizations like autoprefixing and common cross-browser flexbox bugs. Normally you don't need to think about it, but if you'd prefer to add additional postprocessing to your Less output you can specify plugins in the plugin options
// in gatsby-config.js
plugins: [
{
resolve: `gatsby-plugin-less-typescript`,
options: {
postCssPlugins: [somePostCssPlugin()],
},
},
]