Skip to content
This repository was archived by the owner on Dec 26, 2018. It is now read-only.

Commit 192df63

Browse files
committed
autoprefix
1 parent 2b31cb0 commit 192df63

File tree

5 files changed

+24
-7
lines changed

5 files changed

+24
-7
lines changed

lib/compiler.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,7 @@ function processStyle (node, filePath, id) {
227227
var lang = checkLang(node)
228228
return compileAsPromise('style', style, lang)
229229
.then(function (res) {
230-
if (isScoped(node)) {
231-
return rewriteStyle(id, res.source)
232-
} else {
233-
return res
234-
}
230+
return rewriteStyle(id, res.source, isScoped(node))
235231
})
236232
.then(function (res) {
237233
if (process.env.NODE_ENV === 'production') {

lib/compilers/options.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
module.exports = {
2+
autoprefixer: {
3+
remove: false
4+
},
25
babel: {
36
loose: 'all',
47
optional: ['runtime'],

lib/style-rewriter.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var postcss = require('postcss')
22
var selectorParser = require('postcss-selector-parser')
33
var cache = require('lru-cache')(100)
4+
var options = require('./compilers/options')
45

56
var currentId
67
var addId = postcss.plugin('add-id', function () {
@@ -22,17 +23,28 @@ var addId = postcss.plugin('add-id', function () {
2223
*
2324
* @param {String} id
2425
* @param {String} css
26+
* @param {Boolean} scoped
2527
* @return {Promise}
2628
*/
2729

28-
module.exports = function (id, css) {
30+
module.exports = function (id, css, scoped) {
2931
var key = id + '!!' + css
3032
var val = cache.get(key)
3133
if (val) {
3234
return Promise.resolve(val)
3335
} else {
3436
currentId = id
35-
return postcss([addId])
37+
38+
var processors = []
39+
if (scoped) {
40+
processors.push(addId)
41+
}
42+
if (options.autoprefixer !== false) {
43+
var autoprefixer = require('autoprefixer')(options.autoprefixer)
44+
processors.push(autoprefixer)
45+
}
46+
47+
return postcss(processors)
3648
.process(css)
3749
.then(function (res) {
3850
var val = {

test/expects/autoprefix.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
var __vueify_style__ = require("vueify-insert-css").insert("body{-webkit-transform:scale(1);-ms-transform:scale(1);transform:scale(1)}")

test/fixtures/autoprefix.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<style>
2+
body {
3+
transform: scale(1);
4+
}
5+
</style>

0 commit comments

Comments
 (0)