1.7.0 • Published 2 years ago

@guanghechen/gatsby-plugin-stylus v1.7.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Provides drop-in support for Stylus, and generate *.d.ts for Stylus files.

Install

  • npm

    npm install @guanghechen/gatsby-plugin-stylus --save-dev
  • yarn

    yarn add @guanghechen/gatsby-plugin-stylus --dev

Usage

Add configs in gatsby-config.js:

// gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: '@guanghechen/gatsby-plugin-stylus',
      options: {
        shouldUseSourceMap: false,
        shouldGenerateDts: true,
        cssLoaderOptions: {
          modules: {
            localIdentContext: path.resolve(__dirname, 'src'),
            exportLocalsConvention: 'camelCaseOnly',
          }
        }
      }
    }
  ]
}

Then, import *.module.styl in js|jsx|ts|tsx files:

import classes from './style.module.styl'

console.log('classes:', classes)

Options

NameRequiredTypeDefaultDescription
stylusRulefalseobject-Additional webpack rule for *.styl
moduleStylusRulefalseobject-Additional webpack rule for *.module.styl
shouldUseSourceMapfalsebooleanfalseWhether to generate sourcemaps
shouldGenerateDtsfalsebooleanfalseWhether to generate *d.ts for *.module.styl files
cssLoaderOptionsfalseobject-Options for css-loader
stylusLoaderOptionsfalseobject-Options for stylus-loader
postcssLoaderOptionsfalseobject-Options for postcss-loader

  • shouldGenerateDts only works for stylus files enabled module options. You can change the file pattern of the modular stylus by modifying moduleStylusRule.test, similar to the following similar to the following configuration.

    // gatsby-config.js
    module.exports = {
      plugins: [
        {
          resolve: '@guanghechen/gatsby-plugin-stylus',
          options: {
            moduleStylusRule: {
              test: /\.custom\.styl$/,
            },
            shouldGenerateDts: true,
            cssLoaderOptions: {
              modules: {
                localIdentContext: path.resolve(__dirname, 'src'),
                exportLocalsConvention: 'camelCaseOnly',
              }
            }
          }
        }
      ]
    }
1.7.0

2 years ago

1.5.4

3 years ago

1.6.0

3 years ago

1.7.0-alpha.1

3 years ago

1.7.0-alpha.0

3 years ago

1.5.3

3 years ago

1.5.2

3 years ago

1.5.1

3 years ago

1.5.0

3 years ago

1.4.0

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.2.1

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago