Skip to content

A less plugin work with typescript-plugin-css-modules

Notifications You must be signed in to change notification settings

dancon/less-plugin-aliases

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

less-plugin-aliases

A less plugin work with typescript-plugin-css-modules

Work with webpack and typscript-plugin-css-modules

{
  "compilerOptions": {
    "plugins": [
      {
        "name": "typescript-plugin-css-modules",
        "options": {
          "classnameTransform": "camelCase",
          "customMatcher": "\\.less$",
          "customRenderer": "node_modules/less-plugin-aliases/lib/customRender.js"
        }
      }
    ],

    // ...
  }
}

Work alone with less

  import less from 'less'
  import LessPluginAliases from 'less-plugin-aliases'

  less.render(css, {
    ...
    plugins: [
      new LessPluginAliases({
        prefix: '~',
        aliases: {
          common: path(__dirname, 'src/common') // resovle to '/workspace/project/src/common'
        }
      })
    ]
  })

index.less

@import '~common/variables.less';

.container {
  padding: 32px;
  font-size: @fontSize;
  background: @white;

  .header-title {
    font-size: 16px;
  }
}

The plugin will resolve ~common/variables.less to /workspace/project/src/common/variables.less.

About

A less plugin work with typescript-plugin-css-modules

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published