forked from vuetifyjs/vuetify
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostcss.config.js
More file actions
43 lines (35 loc) · 1.01 KB
/
Copy pathpostcss.config.js
File metadata and controls
43 lines (35 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const autoprefixer = require('autoprefixer')
const mqpacker = require('css-mqpacker')
const postcss = require('postcss')
// Define the plugin.
const precision = postcss.plugin('postcss-precision', function () {
const getMatch = (value) => {
const longTest = /(\d+?\.\d{3,})(%|em|px)/gi
value = value + ''
const matches = longTest.exec(value + '')
if (!matches) return null
else return matches[1]
}
return function (style) {
style.walkDecls(function (decl) {
if (decl.value) {
// Grab array of matches.
const value = getMatch(decl.value)
if (!value) return
// Round two decimal places.
const rounded = Math.round(parseFloat(value) * 100) / 100
// Change the value in the tree.
decl.value = decl.value.replace(value, rounded.toString())
}
})
}
})
module.exports = (ctx) => ({
plugins: [
autoprefixer({
browsers: ['ie >= 11', 'safari >= 9', 'last 2 versions', '> 1%']
}),
mqpacker(),
precision()
]
})