Skip to content

onImport has wrong file paths #44

@jednano

Description

@jednano

It looks to me like the first arg of the onImport callback is the file that's doing the importing and every subsequent arg is a file that it imports. Is that correct? If so, it's definitely not working properly. I have 3 files:

/* global.css */
@import foo;
/* page1.css */
@import foo;
@import bar;
/* page2.css */
@import bar;
@import foo;

With the following configuration:

require('postcss-import')({
    path: 'styles/blocks',
    onImport: function(files) {
        console.log('========== import ==========');
        files.forEach(function(file) {
            gutil.log('import:', file);
        });
    }
}),

And here's what I get in the shell:

13:53 $gulp styles
[13:54:12] Using gulpfile z:\gulpfile.js
[13:54:12] Starting 'styles'...
[13:54:12] Finished 'styles' after 37 ms
========== import ===========
[13:54:12] import: z:\styles\sheets\global\global.css
[13:54:12] import: z:\styles\blocks\block-foo.css
========== import ===========
[13:54:12] import: z:\styles\sheets\global\global.css
[13:54:12] import: z:\styles\blocks\block-foo.css
[13:54:12] import: z:\styles\blocks\block-bar.css
========== import ===========
[13:54:12] import: z:\styles\sheets\global\global.css
[13:54:12] import: z:\styles\blocks\block-bar.css
[13:54:12] import: z:\styles\blocks\block-foo.css

Notice how global.css is mentioned 3 times here, when it should have mentioned page1.css and page2.css.

Any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions