giuseppeg / styled-jsx-postcss

Use PostCSS with styled-jsx 💥
MIT License
64 stars 11 forks source link

Not found: node_modules/styled-jsx/server #9

Closed orlin closed 7 years ago

orlin commented 7 years ago

I was trying the webpack alias suggestion, hoping it would fix the Next.js Duplicate declaration "_JSXStyle" error as reported here and there when I ran into another issue:

This dependency was not found in node_modules:

* styled-jsx/server

The above happens after I add this custom next.config.js:

module.exports = {
  webpack: (config, { dev }) => {
    config.resolve.alias = {
      'styled-jsx': '@giuseppeg/styled-jsx-postcss'
    }
    return config
  }
}

Adding the following to the config fixes it:

    config.resolve = {
      'extensions': ['.js', '.jsx']
    }

The file is there but I guess it's being imported without explicitly using the .js extension. I don't know if it's the example or the code that needs changing. I think less config is better. But then maybe there is something wrong with my defaults. I see example of React components being imported without explicit extension, whereas I've so far had to spell out the exact filepaths for components local to a project.

Anyway, I don't quite understand what this alias does. The Next.js example doesn't have it, and it seems <style jsx> is to be used all the same either way.

giuseppeg commented 7 years ago

see #10