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

Commit 0a5d06f

Browse files
committed
Prevent mutability bug with cssnano (minifier) option
poke @magsout
1 parent c9cc0a3 commit 0a5d06f

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

index.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -196,16 +196,19 @@ function cssnext(string, options) {
196196
// minification
197197
if (options.compress) {
198198
var nano = require("cssnano")
199-
200-
/* forced calc options to false */
201-
if (typeof options.compress === "object") {
202-
options.compress.calc = false
203-
}
204-
else {
205-
options.compress = {calc: false}
206-
}
207-
208-
postcssInstance.use(nano(options.compress))
199+
postcssInstance.use(
200+
nano(
201+
assign(
202+
{},
203+
typeof options.compress === "object"
204+
? options.compress
205+
: {},
206+
// forced calc options to false
207+
// since we already used it
208+
{calc: false}
209+
)
210+
)
211+
)
209212
}
210213

211214
// classic API if string is passed

0 commit comments

Comments
 (0)