Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Processing imported files #80

Closed
lmartins opened this issue Sep 11, 2015 · 4 comments
Closed

Processing imported files #80

lmartins opened this issue Sep 11, 2015 · 4 comments

Comments

@lmartins
Copy link

This is probably a misunderstanding on my part of how this works, but im having a few issues, where the modifications made by postcss to my files stop working once I put that code into an import file.

For example, im using postcss-map to create maps, and have this on my main css file:

header{
    background: map(colors, header, bg);
}

However once I pull that code into a partial file than I later import it stops working, and the text is outputted without any modification, meaning it won't replace that map call by the corresponding value.

My gulp file looks like this:


var gulp         = require('gulp');
var plumber      = require('gulp-plumber');
var browserSync  = require('browser-sync');
var postcss      = require('gulp-postcss');
var nestedcss    = require('postcss-nested');
var simplevars   = require('postcss-simple-vars');
var map          = require('postcss-map');
var atImport     = require('postcss-import');
var autoprefixer = require('autoprefixer');
var sourcemaps   = require('gulp-sourcemaps');
var config       = require('../config').markup;


var opts = {
    basePath: 'src/settings/',
    maps: [ 'colors.yml', 'typography.yml' ]
};

gulp.task('css', function () {
    var processors = [
        autoprefixer({browsers: ['last 1 version', 'ie 10']}),
        map(opts),
        nestedcss,
        simplevars,
        atImport
    ];
    return gulp.src('./src/css/main.css')
        .pipe( plumber() )
        .pipe( sourcemaps.init() )
        .pipe( postcss(processors) )
        .pipe( sourcemaps.write('.') )
        .pipe( gulp.dest('build/') )
        .pipe( browserSync.stream({match: "**/*.css"}) );
});

Any tips?

@jednano
Copy link
Contributor

jednano commented Sep 11, 2015

If you want the map plugin to run on imported files you need to either add it to the plugins option or run it after the import plugin.

@lmartins
Copy link
Author

Thanks for the suggestion @jedmao
I was suspecting that would be the case, although im not sure how those examples translate into a Gulp configuration as shown above.

@jednano
Copy link
Contributor

jednano commented Sep 11, 2015

Your processors need to be like this...

var processors = [
    atImport,
    // more plugins...
];

@lmartins
Copy link
Author

Oh... awesome :)
Didn't occur to me it could just a matter of sorting those values.

Many thanks man!

MoOx added a commit that referenced this issue Sep 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants