npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

less-minify

v1.0.13

Published

less文件压缩、只压缩不编译、less变量动态替换、less compress、 less minify

Downloads

10

Readme

重点

此工具,只做LESS文件压缩,不编译。只压缩不编译!!!只压缩不编译!!!只压缩不编译!!!(just compress, not compile!!!),如果你需要编译并压缩,请使用如LESS之类工具。

可以先用着,后续会持续更新

less-minify

css预处理器less源码文件压缩及环境变量动态替换工具。

功能介绍

  1. less源码文件压缩,主要去除多个空格、换行、单行注释、多行注释以及部分语法兼容处理
  2. css源码文件压缩,主要去除多个空格、换行、注释等,对于CSS压缩,如果想要更好的压缩效果和兼容效果,建议使用css-clean
  3. less环境变量动态替换

使用说明

  1. install 安装
    npm install --save-dev less-minify
  1. 引入及使用
const LessMinify = require('less-minify');

// 使用示例1
const input = './style.less'; // 可以是相对路径或者绝对路径
const options = { 
    returnPromise: false, // 是否返回promise对象,默认为false
    compressLevel: 2 // 压缩级别,默认为2
    styleParam: {} // 环境替换变量,
    outputType: 'FILE', // 默认为 FILE,输出文件
    outputPath: '../dist', // 输出路径,为空的话,默认输出在文件当前目录下
    isOutputNameAddMin: true, // 输出的文件名后是否加.min,默认为true
}; // 初始化对象参数
const output = new LessMinify(options).optimize(input);


// 使用示例2
const input = ".name-box .name1 {  color: '#441212'   }"; // 可以是相对路径或者绝对路径
const options = { 
    styleParam: { LESS_MINIFY_STYLE_PARAM_FONT_NORMAL_SIZE: '18px' } // 环境替换变量,
    outputPath: '../dist/test.min.less', // 输出路径,为空的话,默认输出在文件当前目录下
}; // 初始化对象参数
const output = new LessMinify(options).optimize(input);

参数使用说明

input参数

只支持压缩.less或.css结尾的文件。

  1. 单个当前的相对路径,如:'./style.less'
  2. 相对路径数组,如: ['./style.less', './../style2.less']
  3. 单个绝对路径,如:'D:/style/color.less'
  4. 绝对路径数组,如:['D:/style/color.less', 'D:/style/color2.less',]
  5. 可以是文件夹路径,如:'./style',会将文件夹下的.less或.css文件进行压缩替换。
  6. 未压缩的文本内容
对象初始化option参数

| 属性 | 类型 | 说明 | | :-----| :---- | :---- | | returnPromise | Boolean | 是否返回promise对象,默认为false | | compressLevel | Number | 压缩级别[0, 1, 2],0:不压缩、1:主要去除注释、2:在1的基础上去除空,多余符合等。默认为2 | | styleParam | Object | 环境替换变量,如: { LESS_MINIFY_STYLE_PARAM_FONT_NORMAL_SIZE: '18px', LESS_MINIFY_STYLE_PARAM_BACKGROUND_IMAGE_URL: 'XXX', }, 为避免关键字及变量冲突,styleParam对象的key需要以LESS_MINIFY_STYLE_PARAM开头。| | outputType | String | 压缩后输出类型,文本内容或文件,枚举值:CONTENT | FILE,默认为 FILE | | outputPath | String | 如果输出类型为文件,可以指定输出路径,可以为具体文件名,如'./style.min.less',也可以为文件夹路径,如'./dist/'。 | | isOutputNameAddMin | Boolean | 输出的文件名后是否加.min,如'./style.min.less',默认为true |