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

Cannot use together with @csstools/postcss-sass #191

Closed
chalkygames123 opened this issue Mar 19, 2019 · 2 comments
Closed

Cannot use together with @csstools/postcss-sass #191

chalkygames123 opened this issue Mar 19, 2019 · 2 comments

Comments

@chalkygames123
Copy link

chalkygames123 commented Mar 19, 2019

Hi.

I'm trying to use node-sass-magic-importer inside @csstools/postcss-sass, but it fails at the @import statement which depends on the former.

The following are reduced examples.

package.json

{
  "main": "index.js",
  "devDependencies": {
    "@csstools/postcss-sass": "^4.0.0",
    "node-sass-magic-importer": "^5.3.1",
    "postcss": "^7.0.14",
    "postcss-scss": "^2.0.0"
  },
  "dependencies": {
    "normalize.css": "^8.0.1"
  },
  "private": true
}

index.js

const fs = require('fs')
const postcss = require('postcss')
const postcssSass = require('@csstools/postcss-sass')

fs.readFile('input.scss', (err, css) => {
  postcss([
    postcssSass({
      importer: require('node-sass-magic-importer')()
    })
  ])
    .process(css, {
      from: 'input.scss',
      syntax: require('postcss-scss')
    })
    .then(result => {
      console.log(result.css)
    })
})

input.scss

@import '~normalize.css/normalize';

When I run $ node . I get the following error:

(node:40773) UnhandledPromiseRejectionWarning: Error: File to import not found or unreadable
  ╷
1 │ @import '~normalize.css/normalize';
  │         ^^^^^^^^^^^^^^^^^^^^^^^^^^
  ╵
  input.scss#sass 1:9  root stylesheet
...

I'm not sure it really due to node-sass-magic-importer, so I'm sorry if it's not relevant.

Thank you.

@maoberlehner
Copy link
Owner

As far as I can see postcssSass does override the importer option with its own custom importer https://github.com/jonathantneal/postcss-sass/blob/master/index.js#L30 please open an issue in the https://github.com/jonathantneal/postcss-sass project. Thx!

@chalkygames123
Copy link
Author

Thank you for quick response! I'll address it.

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