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:
- Module.export a variables object in a javascript config file (e.g. colors.js).
- 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:
- You should create a java script config file
- In this config file, create an object that will hold your variables as keys
- In the config file, export this variables object, as shown in the 'colors' example given above
- continue with the gulpfile as explained above.
is that fix the problem?