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

Commit

Permalink
Fixed: compress option now works again correctly (1.8.4)
Browse files Browse the repository at this point in the history
Close #195
Close #194
  • Loading branch information
MoOx committed Aug 25, 2015
1 parent 8710e43 commit b5ece99
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 27 deletions.
3 changes: 0 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,3 @@ indent_size = 2

[*.md]
trim_trailing_whitespace = false

[Makefile]
indent_style = tab
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# 1.8.4 - 2015-08-24

- Fixed: `compress` option now works again correctly. A recent update in cssnano
has introduced some minor breaking changes the way cssnext changed plugins
metadata (`pluginName`).
A direct minor change is that `messages` (in console or in css output) now show
real origin (postcss plugin name) instead of a vague "cssnext" origin.
([#195](https://github.com/cssnext/cssnext/issues/195))

# 1.8.3 - 2015-08-06

- Fixed: `url` option (postcss-url) have been updated in order to benefit from
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cssnext",
"version": "1.8.3",
"version": "1.8.4",
"description": "Use tomorrow's CSS syntax, today",
"keywords": [
"css",
Expand Down Expand Up @@ -35,7 +35,7 @@
"chalk": "^1.0.0",
"chokidar": "^1.0.0",
"commander": "^2.3.0",
"cssnano": "^2.0.1",
"cssnano": "^2.6.1",
"exit": "^0.1.2",
"mkdirp": "^0.5.1",
"pixrem": "^1.1.0",
Expand Down Expand Up @@ -80,8 +80,8 @@
"cssrecipes-grid": "^0.4.0",
"cssrecipes-utils": "^0.5.0",
"cssrecipes-vertical-rhythm": "^0.6.0",
"eslint": "^1.0.0-rc-1",
"eslint-loader": "^0.14.2",
"eslint": "^1.0.0",
"eslint-loader": "^1.0.0",
"eslint-plugin-react": "^3.0.0",
"extract-text-webpack-plugin": "^0.8.0",
"file-loader": "^0.8.3",
Expand Down
3 changes: 1 addition & 2 deletions src/__tests__/fixtures/compress.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

/*! sha */
/* blah */
body {
color : red;
color : black;
}
2 changes: 1 addition & 1 deletion src/__tests__/fixtures/compress.default.expected.css
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/*! sha */body{color:red}
/*! sha */body{color:#000}
2 changes: 1 addition & 1 deletion src/__tests__/fixtures/compress.options.expected.css
Original file line number Diff line number Diff line change
@@ -1 +1 @@
body{color:red}
/*! sha */body{color:black}
23 changes: 19 additions & 4 deletions src/__tests__/option.compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,34 @@ test("cssnext compress option", function(t) {
options: utils.readFixture("compress.options.expected").trim(),
}

// compress option
t.equal(
cssnext(input, {compress: true}).trim(),
cssnext(
input,
{
compress: true,
}
).trim(),
expected.default,
"should be able to compress"
)
t.equal(
cssnext(input, {compress: {comments: {removeAll: true}}}).trim(),
cssnext(
input,
{
compress: {
colormin: false,
},
}
).trim(),
expected.options,
"should be able to compress with options"
)
t.equal(
postcss().use(cssnext({compress: true})).process(input).css.trim(),
postcss().use(
cssnext({
compress: true,
})
).process(input).css.trim(),
expected.default,
"should be able to compress even as a postcss plugin"
)
Expand Down
7 changes: 1 addition & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ function cssnext(string, options) {
? {...options.import}
: undefined
)
plugin.postcssPlugin = "cssnext"
postcss.use(plugin)
}

Expand All @@ -94,7 +93,6 @@ function cssnext(string, options) {
? {...options.url}
: undefined
)
plugin.postcssPlugin = "cssnext"
postcss.use(plugin)
}
}
Expand Down Expand Up @@ -129,7 +127,6 @@ function cssnext(string, options) {
? {...features[key]}
: undefined
)
plugin.postcssPlugin = "cssnext"
postcss.use(plugin)
}
})
Expand All @@ -147,9 +144,8 @@ function cssnext(string, options) {

// minification
if (options.compress) {
const nano = require("cssnano")
postcss.use(
nano(
require("cssnano")(
typeof options.compress === "object"
? options.compress
: {}
Expand All @@ -162,7 +158,6 @@ function cssnext(string, options) {
// (which make sense)
if (options.messages) {
optionMessages(options).forEach(plugin => {
plugin.postcssPlugin = "cssnext"
postcss.use(plugin)
})
}
Expand Down
10 changes: 4 additions & 6 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,10 @@ module.exports = {
],
},

plugins: (
[
new webpack.DefinePlugin(buildConfig),
new ExtractTextPlugin("[name].css", {disable: !buildConfig.__PROD__}),
]
.concat(
plugins: ([
new webpack.DefinePlugin(buildConfig),
new ExtractTextPlugin("[name].css", {disable: !buildConfig.__PROD__}),
].concat(
buildConfig.__PROD__
? [
new webpack.optimize.DedupePlugin(),
Expand Down

0 comments on commit b5ece99

Please sign in to comment.