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

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

Open
rocketspops opened this issue Nov 29, 2016 · 11 comments

Comments

@rocketspops
Copy link

rocketspops commented Nov 29, 2016

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

@simonsmith
Copy link
Owner

Hey,

Sounds like you may have bumped into this issue with the import path. We need to get it fixed ASAP so it's on my list.

With regard to the second problem would you not just use @import "suitcss-base" to import from node_modules?

@rocketspops
Copy link
Author

rocketspops commented Nov 29, 2016

@simonsmith using @import "suitcss-base" results in an empty output file as well. I'm not sure if that is the intended functionality of postcss-easy-import or not. As soon as I flip glob: true it no longer automatically imports from node_modules etc.

cc/ @TrySound

@simonsmith
Copy link
Owner

I see, yes. It seems that's the intended behaviour of easy import. Looks like someone opened a pull request to enable globbing and module resolution but I think the author has abandoned postcss-easy-import so not sure when it would get merged.

I added a comment to this issue about it. Not sure what else to suggest there.

@simonsmith
Copy link
Owner

I'm now a collaborator on postcss-easy-import so hopefully I can get that PR merged soon

@rocketspops
Copy link
Author

rocketspops commented Dec 9, 2016 via email

@simonsmith
Copy link
Owner

@rocketspops 2.0 is out - https://github.com/TrySound/postcss-easy-import/releases/tag/2.0.0

Can you see if that resolved your issues?

@rocketspops
Copy link
Author

Hey @simonsmith,

No luck for me. I tried a few things but I keep getting this error message:

Error: ENOENT: no such file or directory, stat '/Users/wwhite11/Code/adel/src/*/stylesheets/suitcss/themes/theme--cti.css'

I'm using suit-preprocessor version 3.0.1. and I also upgraded postcss-easy-import to version 2.0 and specified it with the use option array in the preprocessor config. No luck.

I still can't seem to set the importRoot correctly either. Any ideas?

Thanks,
Billy

@simonsmith
Copy link
Owner

If you're using easy-import via suitcss-preprocessor then the issue might be we haven't moved it to 2.0 yet. There is an outstanding issue to do that piece of work.

Let's revisit this when I've fixed that issue.

@rocketspops
Copy link
Author

rocketspops commented Jan 21, 2017 via email

@simonsmith
Copy link
Owner

I've released a new version of this plugin that uses the latest preprocessor. Apologies for the delay.

@rocketspops
Copy link
Author

Hey @simonsmith I'll take a look! No apology necessary, I appreciate your continued support of these tools. Wish I could be more helpful.

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