Skip to content

Having trouble resolving imports from a directory other than process.cwd() #4

Description

@rocketspops

Hey @simonsmith,

I am trying to @import files using glob and postcss-easy-import but I'm having trouble setting my import directory to something other than process.cwd(). Here is my Gulp task:

var paths = {
  styles: 'src/**/*--suit.css'
};

gulp.task('compile:css', function() {
  return gulp.src(paths.styles)
  .pipe(changedInPlace({ firstPass: true }))
  .pipe(print(function(filepath) { return "Compiled " + "'" + filepath + "'"; }))
  .pipe(suitcss({
    root: 'src',
    'postcss-easy-import': {
      glob: true
    },
    'postcss-calc': { precision: 0 },
    stylelint: {
      extends: 'stylelint-config-suitcss',
      rules: {
        'at-rule-empty-line-before': [ 'always',
          { 'ignore': [ 'all-nested', 'blockless-after-same-name-blockless' ] }
        ]
      }
    }
  }
  ))
  .pipe(rename(function(path){
    path.dirname += '/../';
    path.basename = path.basename.replace(/--suit/, '');
    return path
  }))
  .pipe(gulp.dest('src'));
});

In my css file, I have the following @import statement:

@import "/**/theme-switcher";

However, this results in an empty output file. But, if I change the import statement to:

@import "../../../**/theme-switcher";

The output file is compiled correctly. This confuses me since I've set root: 'src'. What am I missing!?

Also worth noting, once I set the postcss-easy-import option glob: true I'm unable to import suitcss components from the node_modules directory. For example, the following @import statements do not work as I expected:

@import "../../../**/suitcss-base";
@import "../../../**/suitcss-utils-text";

Any ideas?

Thanks,
Billy

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions