GithubHelp home page GithubHelp logo

moox / postcss-cssnext Goto Github PK

View Code? Open in Web Editor NEW
5.3K 126.0 190.0 10.5 MB

`postcss-cssnext` has been deprecated in favor of `postcss-preset-env`.

Home Page: https://moox.io/blog/deprecating-cssnext/

License: MIT License

JavaScript 71.33% CSS 28.67%
postcss css cssnext postcss-plugins javascript

postcss-cssnext's Introduction

postcss-cssnext has been deprecated in favor of postcss-preset-env

Read more at https://moox.io/blog/deprecating-cssnext/

postcss-cssnext

PostCSS plugin to use tomorrow’s CSS syntax, today.

PostCSS-cssnext is a PostCSS plugin that helps you to use the latest CSS syntax today. It transforms CSS specs into more compatible CSS so you don’t need to wait for browser support.


postcss-cssnext's People

Contributors

alerosa avatar bloodyowl avatar chprome avatar danielruf avatar hzlmn avatar jedmao avatar jednano avatar jlhwung avatar lionelb avatar macxim avatar madx avatar magsout avatar marcgg avatar mattdimu avatar moox avatar ntwb avatar nulltask avatar nyalab avatar pascalduez avatar paulmillr avatar purii avatar rafaelrinaldi avatar ryanzim avatar s-panferov avatar sartaj avatar semigradsky avatar sethbergman avatar superol3g avatar tauren avatar tgfjt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

postcss-cssnext's Issues

Add `image-set()` support

Hey, awesome postprocessor! Love it. But will be provided such things like image-set()? I just seen @pepelsbey' presentation and realized that we can to do it with existing @media queries.

Like so:

source.css

E {
    background-image: url(picture.png);
    background-image: image-set(
        url(small.jpg) 1x,
        url(medium.jpg) 2x);
    }

dist.css

E {
    background-image: url(picture.png);
}
@media (min-resolution: 1dppx) {
    E {
        background-image: url(small.jpg)
    }
}
@media (min-resolution: 2dppx) {
    E {
        background-image: url(medium.jpg)
    }
}

Browser support à la autoprefixer

Using a list of browser version we should be able to enable/disable a feature.
Note: some feature might require some other (eg: if custom props are disabled (untouched), but color enabled, var() in color() won't be resolved & browser wont be able to resolve it too since color is unsupported (in this case)). Not sure this can happen, we will see how browsers implement stuff :/

Ref postcss/autoprefixer#284

logo

I'll create a 5$ logo until I want to take time for something better.

Use Autoprefixer 3.0

Autoprefixer 3.0 brings two API changes:

  1. Now there is special autoprefixer-core package for plugin development. It has no file system and CLI code and has no fs-extra dependency.
  2. Browsers now is a part of options object: autoprefixer({ browsers: browsers }).

Potential for collisions in plugin options

There's no documentation about passing options into plugins (e.g., postcss-custom-properties) but it looks like the options are passed to every plugin. That means postcss and all the plugins share the same level of the options and there's a chance for collisions if any of them use properties with the same name.

Maybe make it possible to set the value of a feature to be an options object?

1.0.0 roadmap

Please comment here what you want to see in v1.0.0 & vote (+1/-1) for the things you want to see/don't see.

API

  • browsers option a la autoprefixer (not useful right now, but I hope will be in the future)
  • preserve option that will make output more like autoprefixer (spoiler: dangerous option if we consider how buggy are variables & calc are in Firefox)

Features


You can also consider API & available features are enough for v1.0.0 (but I don't think so).


If you see some other things I don't think about, please express yourself :)

Usage with grunt-postcss

I'm trying to use this as a PostCSS plugin via https://github.com/nDmitry/grunt-postcss

grunt.initConfig({
  postcss: {
    options: {
      map: true,
      processors: [
        require('cssnext')(),
        require('autoprefixer-core')({browsers: 'last 1 version'}).postcss,
        require('csswring').postcss
      ]
    },
    dist: {
      src: 'css/*.css'
    }
  }
});

Running this task throws this:

Warning: Property '0' of object [object Object] is not a function

Other PostCSS seem to work fine.
Also posted here: nDmitry/grunt-postcss#8
Any ideas?

Tests fail on fresh clone

Ran npm install then npm test and 3 tests failed:

not ok 52 should throw an error
  ---
    operator: ok
    expected: true
    actual:   null
  ...
not ok 53 should output a readable error
  ---
    operator: ok
    expected: true
    actual:   false
  ...
not ok 54 should show the url where to report bugs
  ---
    operator: ok
    expected: true
    actual:   false
  ...

Add rem fallback

Not sure if this should be the default behavior.
We need make something like autoprefixer to select browser support.

enable sourcemap output other than inline

Since cssnext only return process().css, sourcemap is only suported when inlined in output. If specific sourcemap options are provided to postcss ( map, from) process() return an object with {css: "output", map: "sourcemap"}
To avoir breaking changes, perhaps cssnext should return an object only if postcss return map prop.

color/var bug

:root {
    --base-link-color: #000;
    --base-link-color-hover: color(var(--base-link-color) lightness(+10%));
}
a {
    color : var(--base-link-color-hover);
}

should yields into something like:

a {
 color: rgb(255, 51, 51);
}

And not throw an error: Error: Unable to parse color from string var(--base-link-color)

upgrade to postcss 4

  • get ride of .childs everywhere
  • some new apis
  • better errors

https://github.com/postcss/postcss/releases/tag/4.0.0

Plugins to update:

  • postcss-import
  • postcss-custom-properties
  • postcss-calc
  • postcss-custom-media
  • postcss-media-minmax
  • postcss-custom-selectors
  • postcss-color-rebeccapurple
  • postcss-color-hwb
  • postcss-color-gray
  • postcss-color-hex-alpha
  • postcss-color-function
  • postcss-font-variant
  • pleeease-filters
  • autoprefixer-core v5
  • csswring v3

Split up Node API and CLI

As is done with autoprefixer and autoprefixer-core. It's nice be able to install just the Node API because any module that wants to use this – or a complicated build process – is unlikely to use this tool's CLI.

Error with empty file

@import "header.css"

if file is empty :

>> File "header.css" changed.
Running "cssnext:dist" (cssnext) task
Warning: Cannot set property 'before' of undefined Use --force to continue.

Non clear syntax error with unclosed var(

body {
  font-size: var(--fontSize;
}

Give on the playground

TypeError: balanced(...) is undefined

And with cli

cssnext encounters an error:

Cannot read property 'body' of undefined

    at resolveValue (/Users/MoOx/Sync/Development/cssnext/playground/node_modules/cssnext/node_modules/postcss-custom-properties/index.js:96:66)
    at /Users/MoOx/Sync/Development/cssnext/playground/node_modules/cssnext/node_modules/postcss-custom-properties/index.js:62:23
    at /Users/MoOx/Sync/Development/cssnext/playground/node_modules/cssnext/node_modules/postcss/lib/container.js:402:30
    at Rule.Container.each (/Users/MoOx/Sync/Development/cssnext/playground/node_modules/cssnext/node_modules/postcss/lib/container.js:88:20)
    at Rule.Container.WithDecls.constructor$1.eachDecl (/Users/MoOx/Sync/Development/cssnext/playground/node_modules/cssnext/node_modules/postcss/lib/container.js:400:21)
    at /Users/MoOx/Sync/Development/cssnext/playground/node_modules/cssnext/node_modules/postcss/lib/container.js:331:36
    at Root.Container.each (/Users/MoOx/Sync/Development/cssnext/playground/node_modules/cssnext/node_modules/postcss/lib/container.js:88:20)
    at Root.Container.WithRules.constructor$0.eachDecl (/Users/MoOx/Sync/Development/cssnext/playground/node_modules/cssnext/node_modules/postcss/lib/container.js:329:21)
    at /Users/MoOx/Sync/Development/cssnext/playground/node_modules/cssnext/node_modules/postcss-custom-properties/index.js:55:11
    at PostCSS.process (/Users/MoOx/Sync/Development/cssnext/playground/node_modules/cssnext/node_modules/postcss/lib/postcss.js:34:28)

@import should work with relative paths

Tested with gulp-cssnext, I noticed that @import rules don't work if the path is being relative to the .css file. Given the following structure

.
├── css
│   ├── import.css
│   └── sub-folder
│       ├── import-abs.css
│       └── import-rel.css
├── gulpfile.js
├── out
│   └── import-abs.css
└── package.json

With import-abs.css having

@import "css/import.css";

And import-rel.css having

@import "../import.css";

And the gulpfile.js having this

var gulp = require("gulp");
var cssnext = require("gulp-cssnext")

gulp.task("css:relative", function() {
  gulp.src("css/sub-folder/import-rel.css")
    .pipe(cssnext({
        compress : true
    }))
    .pipe(gulp.dest("./out"))
});

gulp.task("css:absolute", function() {
  gulp.src("css/sub-folder/import-abs.css")
    .pipe(cssnext({
        compress : true
    }))
    .pipe(gulp.dest("./out"))
});

Then, gulp css:relative returns

[11:59:29] Using gulpfile ~/Desktop/cssnext-import-bug/gulpfile.js
[11:59:29] Starting 'css:relative'...
[11:59:29] Finished 'css:relative' after 16 ms
events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: undefined1:1: Failed to find ../import.css
    in [
        /Users/Damien/Desktop/cssnext-import-bug
    ]
    at resolveFilename (/Users/Damien/Desktop/cssnext-import-bug/node_modules/gulp-cssnext/node_modules/cssnext/node_modules/postcss-import/index.js:133:11)
    at readAtImport (/Users/Damien/Desktop/cssnext-import-bug/node_modules/gulp-cssnext/node_modules/cssnext/node_modules/postcss-import/index.js:82:26)
    at checkAtRule (/Users/Damien/Desktop/cssnext-import-bug/node_modules/gulp-cssnext/node_modules/cssnext/node_modules/postcss-import/index.js:61:5)
    at /Users/Damien/Desktop/cssnext-import-bug/node_modules/gulp-cssnext/node_modules/cssnext/node_modules/postcss/lib/container.js:374:30
    at /Users/Damien/Desktop/cssnext-import-bug/node_modules/gulp-cssnext/node_modules/cssnext/node_modules/postcss/lib/container.js:110:26
    at Root.Container.each (/Users/Damien/Desktop/cssnext-import-bug/node_modules/gulp-cssnext/node_modules/cssnext/node_modules/postcss/lib/container.js:88:20)
    at Root.Container.eachInside (/Users/Damien/Desktop/cssnext-import-bug/node_modules/gulp-cssnext/node_modules/cssnext/node_modules/postcss/lib/container.js:109:21)
    at Root.Container.WithRules.constructor$0.eachAtRule (/Users/Damien/Desktop/cssnext-import-bug/node_modules/gulp-cssnext/node_modules/cssnext/node_modules/postcss/lib/container.js:372:21)
    at parseStyles (/Users/Damien/Desktop/cssnext-import-bug/node_modules/gulp-cssnext/node_modules/cssnext/node_modules/postcss-import/index.js:56:10)
    at /Users/Damien/Desktop/cssnext-import-bug/node_modules/gulp-cssnext/node_modules/cssnext/node_modules/postcss-import/index.js:45:5

And of course gulp css:absolute works like expected

[11:59:54] Using gulpfile ~/Desktop/cssnext-import-bug/gulpfile.js
[11:59:54] Starting 'css:absolute'...
[11:59:54] Finished 'css:absolute' after 14 ms

🎉

Error: Cannot find module 'exit'

Using the command npm run build on the grid component cssrecipes I get this error:

module.js:340
    throw err;
          ^
Error: Cannot find module 'exit'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/Users/mac/Sandbox/grid/node_modules/cssnext/bin/cssnext:9:12)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)

I tested with version 0.5.0, it works, but since 0.6.0 I get an error.

Round issue

:root {
  --fontSize: 3rem;
}

body { font-size: calc(var(--fontSize) * 1.2); }

gives

body { font-size: 3.5999999999999996rem; }

Group media queries

CSS next :

/* custom media query usage */
@media (--viewport-medium) {
  body { font-size: calc(var(--fontSize) * 1.2); }
}

/* custom media query usage */
@media (--viewport-medium) {
  p { font-size: calc(var(--fontSize) * 1.2); }
}

CSSnext generates

/* custom media query usage */
@media (max-width: 50em) {
  body { font-size: 1.2rem; }
}


/* custom media query usage */
@media (max-width: 50em) {
  p { font-size: 1.2rem; }
}

It would be nice if media queries could be grouped:

/* custom media query usage */
@media (max-width: 50em) {
  body { font-size: 1.2rem; }
  p { font-size: 1.2rem; }
}

No ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.