You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

change-style-vars

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

change-style-vars

scss、less util。To change the value of the sass or less variable 。and render to css

1.0.2
latest
Source
npmnpm
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

cssAdapter

To change the value of the sass or less variable

用于改变 scss、less、sass等样式文件的变量。

用法

const StyleFile = require('./adapter')
const fs = require('fs')
const path = require('path')
const style = new StyleFile({
  language: 'scss',
  from: 'test/scssTheme/index.scss',
  to: 'test/scssTheme/dist/theme.css'
})


let styleCss = fs.readFileSync('./test/scssTheme/index.scss')
let variable = {
  '$--color-white': '#fff'
}

async function start() {
  await style.changeVars(styleCss, variable)
  let renderCssResult = await style.toCss()
  // assetsPath 生成静态资源文件目录
  const urlOption = [
    { filter: /\.ttf$/, url: 'copy', useHash: true, assetsPath: path.resolve('test','scssTheme', 'dist','fonts') },
    { filter: /\.woff$/, url: 'copy', useHash: true, assetsPath: path.resolve('test','scssTheme', 'dist','fonts') }
  ]
  let rs = await style.postcssUrl(renderCssResult.css, urlOption)
  fs.writeFileSync(path.resolve('test','scssTheme','dist') + '/theme.css', rs.css)
}

start()

FAQs

Package last updated on 18 Jan 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