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

Can I use webpack resolve.extensions = [".css"] and use import './table' instead of './table.css' in js #295

Open
yinsang opened this issue Dec 17, 2020 · 1 comment

Comments

@yinsang
Copy link

yinsang commented Dec 17, 2020

Course
image

// webpack.config.js

  resolve: {
    extensions: ['*', '.js', '.json', '.jsx', '.tsx', '.ts', '.css', '*.css', '.scss'],
  },

// RuntimeStyleResolution.js

/**
 * @file Demonstrates runtime "styleName" resolution.
 * @see https://github.com/gajus/babel-plugin-react-css-modules#runtime-stylename-resolution
 */

import React from 'react';
import './table';

export default () => {
  return <div styleName='table'>
    <div styleName='row'>
      <div styleName={'cell' + (Math.random() > 0.5 ? ' yellow' : '')}>A2</div>
      <div styleName={'cell' + (Math.random() > 0.5 ? ' yellow' : '')}>B2</div>
      <div styleName={'cell' + (Math.random() > 0.5 ? ' yellow' : '')}>C2</div>
    </div>
  </div>;
};

@yinsang
Copy link
Author

yinsang commented Dec 17, 2020

I try to debug. It's your notForPlugin function in index.js return false while

extension === './table'

not './table.css'
course the problem.

@yinsang yinsang changed the title Can I use webpack resolve.extensions = [".css"] and use import 'xxx' instead of 'xxx.css' in jsx? Can I use webpack resolve.extensions = [".css"] and use import './table' instead of './table.css' in js Dec 18, 2020
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

1 participant