Socket
Book a DemoInstallSign in
Socket

@hon2a/less-vars-loader

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hon2a/less-vars-loader

Webpack loader providing a seamless bridge from Less variable sheets to JS files

0.0.5
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

@hon2a/less-vars-loader

@hon2a/less-vars-loader is a Webpack loader providing a seamless bridge from Less variable sheets to JS files.

Use

Use the loader to extract variables from Less variable sheets (including imports, transitively) and bring them into a JS file as an object. Use inline loader syntax to set this up:

import theme from '!@hon2a/less-vars-loader!./path/to/vars.less'

Note: Use a leading ! to prevent use of other loaders.

If you're not using the file also in regular imports, you may also set up the loader in webpack.config.js and take advantage of the transform option:

module.exports = {
  module: {
    rules: [
      {
        test: /\.vars\.less$/,
        use: '@hon2a/less-vars-loader',
        options: {
          transform: ([key, value]) => [camelCase(key), /^\d+px$/.test(value) ? parseInt(value, 10) : value],
          lessOptions: { javascriptEnabled: true }
        }
      }
    ]
  }
}

Note: This loader needs to go before other loaders matching the test if there are any (e.g. when also using less-loader to load other .less files).

Development

Install

Install dependencies using:

npm install

Develop

After you modify sources, run the following (or set up your IDE to do it for you):

  • format the code using npm run format
  • lint it using npm run lint
  • test it using npm test

and fix the errors, if there are any.

Publish

Publishing is done in two steps:

  • Create a new version tag and push it to the repository:
    npm version <patch|minor|major>
    git push --follow-tags
    
  • Build and publish the new version as a npm package:
    npm publish --access public
    

FAQs

Package last updated on 28 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.