增加右键菜单编译;增加快捷键绑定

pull/19/head
宇天 2018-12-21 15:57:39 +08:00
parent 4bd21cfa9d
commit 1a75280ef4
7 changed files with 72 additions and 1767 deletions

View File

@ -1,5 +1,7 @@
.vscode/**
.vscode-test/**
test/**
package-lock.json
.travis.yml
.gitignore

View File

@ -1,5 +1,9 @@
# 更新日志
## [1.1.0] 2018-12-21
- 增加右键菜单编译(此命令不受配置中的过滤条件限制,只判断是否scss文件)
## [1.0.4] 2018-12-17
- 日常维护

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -11,6 +11,13 @@
> 对于小项目来说, webpack等各种工程化工具, 实在过于重, 配置又繁琐。 而且还要安装一大堆模块。
> 有时候,我们只想简单的使用scss带来的便捷而已。所以本着这个目的, 我自己写了一个vsc的插件, 可以在scss文件保存的时候, 自动编译成css文件(存于当前目录),并且自动补全浏览器前缀。
## 易用性
> 本插件只有4个配置选项,而且都是可选的。真正的开箱即用。
>> - 是否保存后自动编译; 默认 `是`
>> - 是否补全浏览器的前缀; 默认 `是`。 非常实用的一个选项, 在不需要的情况下可以关闭, 以加快编译速度。
>> - 编译输出类型, 默认`压缩输出`。 可以自定义, 可以同时编译输出多种格式的文件。
>> - 忽略正则。 这个也是非常实用的功能, 毕竟现在的公司前端项目, 都使用webpack等打包工具, 这时候就可以临时停用本插件; 现在呢还有个更加方便的方式, 就是把使用了webpack的项目的目录名配置到这里, 这样插件就会自动忽略这个目录下的scss文件编译了。
## 兼容性
> 理论上, 兼容Linux/MacOS/Windows, 不过我只在Linux/MacOS下测试过, 用Windows的童鞋请自行测试,有什么问题, 可以提issue。
@ -19,7 +26,8 @@
> 直接在商店搜索安装即可。
## .browserslistrc 范例
## .browserslistrc 示例
> 这只是个示例, 可自行根据项目需求, 修改配置。 没有配置则默认为 `last 2 version`
```
ie > 9

View File

@ -8,7 +8,6 @@
const vsc = require('vscode')
const path = require('path')
const cp = require('child_process')
const fs = require('iofs')
const scss = require('node-sass')
@ -16,13 +15,7 @@ const postcss = require('postcss')
const autoprefixer = require('autoprefixer')
let prefixer
const std = vsc.window.createOutputChannel('scss-to-css')
std.out = function(msg) {
std.appendLine(msg)
}
const log = function(...args) {
console.log.apply(console, args)
}
const log = console.log
const render = function(style, file) {
return new Promise((resolve, reject) => {
@ -96,7 +89,7 @@ const Compiler = {
})
})
.catch(err => {
std.out(err)
vsc.window.showInformationMessage(err)
})
},
@ -130,8 +123,6 @@ const Compiler = {
}
function activate(ctx) {
// log('hello, the extend scss--to-css is running....')
let folders = vsc.workspace.workspaceFolders
let wsf = ''
let browsersrc = ''
@ -140,6 +131,12 @@ function activate(ctx) {
}
if (wsf) {
browsersrc = path.join(wsf, '.browserslistrc')
} else {
let editor = vsc.window.activeTextEditor
if (editor) {
wsf = path.dirname(editor.document.fileName)
browsersrc = path.join(wsf, '.browserslistrc')
}
}
if (fs.exists(browsersrc)) {
@ -163,10 +160,15 @@ function activate(ctx) {
vsc.workspace.onDidSaveTextDocument(doc => {
Compiler.filter(doc)
})
// let cmd = vsc.commands.registerCommand('ScssCompiler.compile', function(r) {
// log('----------------------------====================-----------------')
// })
// ctx.subscriptions.push(cmd)
let cmd = vsc.commands.registerCommand('Scss2css.compile', _ => {
let editor = vsc.window.activeTextEditor
if (editor) {
Compiler.compile(editor.document)
}
})
ctx.subscriptions.push(cmd)
}
function deactivate() {}

1749
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
"name": "scss-to-css",
"displayName": "scss-to-css",
"description": "🔥 最简单易用的SCSS编译器, 可自动编译scss文件及补全前缀",
"version": "1.0.4",
"version": "1.1.0",
"publisher": "yutent",
"author": "Yutent [@yutent]",
"icon": "logo.png",
@ -13,10 +13,25 @@
"activationEvents": ["*"],
"main": "./index",
"contributes": {
"context": [
"commands": [
{
"command": "Scss2css.compile",
"title": "Compile this scss file"
"title": "Compile this scss..."
}
],
"menus": {
"editor/context": [
{
"when": "!inOutput",
"command": "Scss2css.compile",
"title": "Compile this scss..."
}
]
},
"keybindings": [
{
"command": "Scss2css.compile",
"key": "cmd+shift+c"
}
],
"configuration": {