修复autoprefixer的配置

pull/19/head
宇天 2018-12-03 14:08:33 +08:00
parent 9c97ded959
commit 9563e8adbe
5 changed files with 964 additions and 129 deletions

1
.gitignore vendored
View File

@ -9,6 +9,7 @@
# Files that might appear on external disk # Files that might appear on external disk
.Spotlight-V100 .Spotlight-V100
.Trashes .Trashes
package-lock.json
node_modules node_modules
*.vsix *.vsix

View File

@ -1,3 +1,4 @@
.vscode/** .vscode/**
package-lock.json
.gitignore .gitignore

View File

@ -14,10 +14,10 @@ const fs = require('iofs')
const scss = require('node-sass') const scss = require('node-sass')
const postcss = require('postcss') const postcss = require('postcss')
const autoprefixer = require('autoprefixer') const autoprefixer = require('autoprefixer')
const prefixer = postcss().use(autoprefixer()) let prefixer
const std = vsc.window.createOutputChannel('scss-to-css') const std = vsc.window.createOutputChannel('scss-to-css')
std.out = function() { std.out = function(msg) {
std.appendLine(msg) std.appendLine(msg)
} }
const log = function(...args) { const log = function(...args) {
@ -109,7 +109,7 @@ const Compiler = {
}) })
}) })
.catch(err => { .catch(err => {
log(err) std.out(err)
}) })
}, },
@ -143,12 +143,36 @@ const Compiler = {
} }
function activate(ctx) { function activate(ctx) {
// log('hello, the extend scss-compiler is running....') // log('hello, the extend scss--to-css is running....')
let folders = vsc.workspace.workspaceFolders
let wsf = ''
let browsersrc = ''
if (folders && folders.length) {
wsf = folders[0].uri.path
}
if (wsf) {
browsersrc = path.join(wsf, '.browserslistrc')
}
if (fs.exists(browsersrc)) {
options.browsers = fs
.cat(browsersrc)
.toString()
.split(/[\n\r]/)
}
let conf = vsc.workspace.getConfiguration('Scss2css') let conf = vsc.workspace.getConfiguration('Scss2css')
Object.assign(options, conf) Object.assign(options, conf)
options.output = options.output.split('|').map(it => it.trim()) options.output = options.output.split('|').map(it => it.trim())
prefixer = postcss().use(
autoprefixer({
browsers: options.browsers
})
)
vsc.workspace.onDidSaveTextDocument(doc => { vsc.workspace.onDidSaveTextDocument(doc => {
Compiler.filter(doc) Compiler.filter(doc)
}) })

1057
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
"name": "scss-to-css", "name": "scss-to-css",
"displayName": "scss-to-css", "displayName": "scss-to-css",
"description": "最简单易用的SCSS编译器, 可自动编译scss文件及补全前缀", "description": "最简单易用的SCSS编译器, 可自动编译scss文件及补全前缀",
"version": "1.0.0", "version": "1.0.2",
"publisher": "yutent", "publisher": "yutent",
"author": "Yutent [@yutent]", "author": "Yutent [@yutent]",
"icon": "logo.png", "icon": "logo.png",