postcss / postcss-simple-vars

PostCSS plugin for Sass-like variables

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reverse import

FezVrasta opened this issue · comments

Not sure if the title is clear.. well, actually I'm sure it is not.

Example:

// a.sss
$foo: 1

// b.sss
.b
  order: $foo

// c.sss
@import 'a'
@import 'b'

In this case, $foo in b.sss is undefined.
With Stylus it worked correctly (I'm converting a big Stylus code base).

Is it expected or am I doing something wrong somewhere else maybe?

In PostCSS logic is different.

You import a.pcss to c.pcss.

Not to global state.

So I have to change the imports of the whole code base, d'oh!

Thanks, it makes sense.

The following instructions will solve the problem:

  1. Module.export a variables object in a javascript config file (e.g. colors.js).
  2. Configure postcss-simple-vars accordingly to use this module.

For comple example and instructions refer to 'Variables' section in the post-css-simple-vars description (github.com):

`// config/colors.js

module.exports = {
blue: '#056ef0'
}

// gulpfile.js

var colors = require('./config/colors');
var vars = require('postcss-simple-vars')

gulp.task('css', function () {
return gulp.src('./src/*.css')
.pipe(postcss([ vars({ variables: colors }) ]))
.pipe(gulp.dest('./dest'));
});`

HI, I have fallen on the same problem, but the instructions above make no sense to me. I understand the code needed for gulpfile.js , but cannot grasp the first step.

I break down the first step further:

  1. You should create a java script config file
  2. In this config file, create an object that will hold your variables as keys
  3. In the config file, export this variables object, as shown in the 'colors' example given above
  4. continue with the gulpfile as explained above.
    is that fix the problem?