Skip to content

composes using absolute paths via webpack context doesn't resolve #109

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

Closed
besh opened this issue Jul 7, 2017 · 3 comments
Closed

composes using absolute paths via webpack context doesn't resolve #109

besh opened this issue Jul 7, 2017 · 3 comments
Labels

Comments

@besh
Copy link

besh commented Jul 7, 2017

Hey there. So, what I think that I'm observing is that when I use this plugin, I get module build errors because

.class {
  composes: someclass from shared_styles/colors.css;` 
}

now resolves to

.class {
  composes: someclass from '/user/path/stuff/project/client/components/SomeComponent/SomeComponent/shared_styles/colors.css.';
}

Prior to using this plugin, composes was properly using the context key in webpack and resolving paths as

.class {
  composes: someclass from '/user/path/stuff/project/client/shared_styles/colors.css';
}

I believe I am setting everything correctly with the plugin. Doing some light logging within the plugin's index.js file, it is traversing and finding the correct js files that are attempting to use the styleName attribute.

Here is my webpack config for js stuff (shortened for brevity).

const APP_DIR  = path.resolve(__dirname, '../client');
{
  context: APP_DIR
  module: {
    rules: [
      {
        test: /\.js$/,
        include: APP_DIR,
        exclude: /node_modules/,
        use: [{
          loader: 'react-hot-loader/webpack'
        },{
          loader: 'babel-loader',
          options: {
            babelrc: false,
            presets: [
              ['es2015', { 'modules': false }],
              'stage-0',
              'react'
            ],
            plugins: [
              [
                'react-intl', {
                  messagesDir: './i18n/messages',
                  enforceDescriptions: true
                }
              ],[
                'react-css-modules', {
                  context: APP_DIR
                }
              ]
            ]
          }
        }]
      }
    ]
  }
}

I am not aliasing anything in webpack and composes is resolving from the context key without including this plugin. Any guidance here would be appreciated. I'll keep digging too.

Not sure if this is somewhat related to #25?

@besh
Copy link
Author

besh commented Jul 14, 2017

@gajus any guidance on this one? Sorry if I'm missing something really dumb. With your recent article here, I'm even more excited to try this plugin out.

@gajus gajus added the question label Jul 14, 2017
@SirbyAlive
Copy link

SirbyAlive commented Jul 18, 2017

I've been stuck on the same problem.
On fetch in requireCssModule, the path resolve is used, totally outside of the babel resolver, so no configuration can actually affect how the path is resolved and it is always either resolved relatively from the file or absolutely.

@gajus
Copy link
Owner

gajus commented Nov 27, 2018

@gajus gajus closed this as completed Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants