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

Commit fd7525a

Browse files
committed
use cssnano instead of clean-css
1 parent fe11c1e commit fd7525a

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed

lib/compiler.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ if (process.env.NODE_ENV === 'production') {
1818
var htmlMinifyOptions = {
1919
customAttrSurround: [[/@/, new RegExp('')], [/:/, new RegExp('')]]
2020
}
21-
var CleanCSS = require('clean-css')
22-
var cssMinifier = new CleanCSS()
2321
}
2422

2523
// expose compiler
@@ -229,12 +227,6 @@ function processStyle (node, filePath, id) {
229227
.then(function (res) {
230228
return rewriteStyle(id, res.source, isScoped(node))
231229
})
232-
.then(function (res) {
233-
if (process.env.NODE_ENV === 'production') {
234-
res.source = cssMinifier.minify(res.source).styles
235-
}
236-
return res
237-
})
238230
}
239231

240232
/**

lib/style-rewriter.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,24 @@ module.exports = function (id, css, scoped) {
4444
if (val) {
4545
return Promise.resolve(val)
4646
} else {
47-
currentId = id
48-
49-
var processors = []
47+
var plugins = []
48+
// scoped css rewrite
5049
if (scoped) {
51-
processors.push(addId)
50+
plugins.push(addId)
5251
}
52+
// autoprefixing
5353
if (options.autoprefixer !== false) {
5454
var autoprefixer = require('autoprefixer')(options.autoprefixer)
55-
processors.push(autoprefixer)
55+
plugins.push(autoprefixer)
5656
}
57-
58-
return postcss(processors)
57+
// minification
58+
if (process.env.NODE_ENV === 'production') {
59+
plugins.push(require('cssnano')({
60+
autoprefixer: false
61+
}))
62+
}
63+
currentId = id
64+
return postcss(plugins)
5965
.process(css)
6066
.then(function (res) {
6167
var val = {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"dependencies": {
2424
"autoprefixer": "^6.0.3",
2525
"babel": "^5.8.23",
26-
"clean-css": "^3.4.4",
26+
"cssnano": "^3.3.2",
2727
"es6-promise": "^3.0.2",
2828
"hash-sum": "^1.0.2",
2929
"html-minifier": "^0.8.0",

test/expects/myth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
var __vueify_style__ = require("vueify-insert-css").insert("a{color:#847AD1}pre{padding:10px;margin:20px}")
1+
var __vueify_style__ = require("vueify-insert-css").insert("a{color:#847ad1}pre{padding:10px;margin:20px}")

0 commit comments

Comments
 (0)