Atom Editor 插件 atom-less 的使用方法

1、下載安裝 atom-less

atom-less 項目在這裏:https://github.com/schmuli/atom-lesscss

安裝方法請參考這篇博文:http://blog.csdn.net/kingittiger/article/details/51881442git

2、使用方法

atom-less 的使用略顯奇葩。跟其它 LESS 插件不一樣,它須要在每一個 less 文件的頭部都寫上配置行,編譯器讀取這行配置,才能夠正常運做。好處是,不一樣的 less 就能夠用不一樣的配置,作到靈活輸出,不用頻繁去設置全局參數。github

1. 官方參考說明 README.md

# atom-less package

An Atom package that auto-compiles LESS files on save, with support for LESS plugins, Clean-CSS and AutoPrefixer.

### Configuration

On the first line of LESS files, add a valid JSON comment, not including the outer brackets ('{' and '}'), with the following properties:

- **"main"**: `string` -
    The relative or absolute path to the main LESS file to be compiled (ignores all other options)
- **"out"**: `boolean|string` -
    `true` to output using the filename, or a string specifying a name to use
- **"compress"**: `boolean` -
    Use Less.JS built-in compression (not compatible with Clean-CSS or Source Maps)
- **"strictMath"**: `boolean` -
    Require brackets around math expressions
- **"sourceMap"**: `boolean|Object` -
    `true` to turn on source maps, or an object specifying LESS source map properties
- **"cleancss"**: `string|object` -
    a string specifying the 'compatibility' property,
    or an object specifying the Clean-CSS properties (not compatible with Source Maps)
- **"autoprefixer"**: `string|object` -
    a `;` separated string specifying the 'browsers' property,
    or an object specifying the AutoPrefixer properties

Other LESS compiler options might work but are untested at this point.

### Road Map
1. Remove dependency on inline comments, and instead use a .lesscfg project file, allowing easier configuration and automatic support of additional LESS plugins
2. Change callback passing to use Promises

來源:https://atom.io/packages/atom-lessexpress

2. 經常使用選項配置

其實經常使用的選項就兩個:out 和 compressout 配置輸出,compress 配置是否壓縮。配置要寫成 JSON 註釋形式,但不包含花括號 { }less

配置形式:ui

// "<選項1>": "<配置1>", "<選項2>": "<配置2>", ...

下面舉幾個例子:this

// "out": true                  ## 輸出同名的 css 文件,不壓縮
// "out": "test.css"               ## 輸出名爲 test.css 文件,不壓縮
// "out": true, "compress": true     ## 輸出名爲 test.css 文件,壓縮

3. 常見問題問答

相關文章
相關標籤/搜索