pull/19/head
宇天 2019-06-10 16:18:57 +08:00
parent d945af6d3e
commit ca6afc5cc8
6 changed files with 56 additions and 47 deletions

View File

@ -1,5 +1,9 @@
# 更新日志(Changed Logs) # 更新日志(Changed Logs)
## [2.1.0] 2019-06-10
- 更新libsass到最新版
- 增加异常信息输出
## [2.0.0] 2019-02-14 ## [2.0.0] 2019-02-14
- 大版本改动,移除 `.browserslistrc`的支持, 改用`.scssrc`; - 大版本改动,移除 `.browserslistrc`的支持, 改用`.scssrc`;

View File

@ -16,6 +16,10 @@ const autoprefixer = require('autoprefixer')
let prefixer let prefixer
const log = console.log const log = console.log
const std = vsc.window.createOutputChannel('scss-to-css')
std.out = function(msg) {
std.appendLine(msg)
}
const render = function(style, file) { const render = function(style, file) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -23,7 +27,7 @@ const render = function(style, file) {
if (res && res.text) { if (res && res.text) {
resolve(res.text) resolve(res.text)
} else { } else {
reject(res) reject(res && res.message)
} }
}) })
}) })
@ -41,15 +45,19 @@ const compileCss = (style, entry, output) => {
let tmp = output.replace(options.workspace, '.') let tmp = output.replace(options.workspace, '.')
output = path.join(options.outdir, tmp) output = path.join(options.outdir, tmp)
} }
return render(style, entry).then(css => { return render(style, entry)
if (options.autoPrefixer) { .then(css => {
return prefixer.process(css, { from: '', to: '' }).then(result => { if (options.autoPrefixer) {
return { css: result.css, output } return prefixer.process(css, { from: '', to: '' }).then(result => {
}) return { css: result.css, output }
} else { })
return { css, output } } else {
} return { css, output }
}) }
})
.catch(err => {
std.out(err)
})
} }
const Compiler = { const Compiler = {
@ -172,12 +180,15 @@ function __init__() {
) )
} }
function activate(ctx) { function deactivate() {}
exports.activate = function(ctx) {
__init__() __init__()
vsc.workspace.onDidChangeConfiguration(__init__) vsc.workspace.onDidChangeConfiguration(__init__)
vsc.workspace.onDidSaveTextDocument(doc => { vsc.workspace.onDidSaveTextDocument(doc => {
std.clear()
Compiler.filter(doc) Compiler.filter(doc)
}) })
@ -190,8 +201,4 @@ function activate(ctx) {
}) })
ctx.subscriptions.push(cmd) ctx.subscriptions.push(cmd)
} }
function deactivate() {}
exports.activate = activate
exports.deactivate = deactivate exports.deactivate = deactivate

File diff suppressed because one or more lines are too long

View File

@ -2,7 +2,7 @@
"name": "scss-to-css", "name": "scss-to-css",
"displayName": "scss-to-css", "displayName": "scss-to-css",
"description": "🔥 The easiest way to compile scss file to css. And autoprefixer at the same time.", "description": "🔥 The easiest way to compile scss file to css. And autoprefixer at the same time.",
"version": "2.0.0", "version": "2.1.0",
"publisher": "yutent", "publisher": "yutent",
"author": "Yutent [@yutent]", "author": "Yutent [@yutent]",
"icon": "logo.png", "icon": "logo.png",

View File

@ -1 +1 @@
ul{display:-webkit-flex;display:-ms-flexbox;display:flex}ul li{-webkit-flex:2;-ms-flex:2;flex:2;color:#fff} ul{display:flex}ul li{flex:2;color:#fff}

View File

@ -2,5 +2,5 @@ ul {
display: flex; display: flex;
li {flex: 2;color: #fff;} li {flex: 2;color: #fff;}
}
}