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

Example with typescript? #274

Open
tomasz-szepczynski opened this issue Oct 4, 2019 · 3 comments
Open

Example with typescript? #274

tomasz-szepczynski opened this issue Oct 4, 2019 · 3 comments
Labels

Comments

@tomasz-szepczynski
Copy link

tomasz-szepczynski commented Oct 4, 2019

1)Following the tutorial and modyfing .babelrc did not change 'stylename' to 'classname'.
webpack.js:
const context = path.resolve(__dirname, '..');
.babelrc

["react-css-modules", {
    "webpackHotModuleReloading": true,
    "context": ".."
  }],

2)I tried config from demo example :

  {
    test: /\.tsx?$/,
    loader: 'ts-loader',
    query: {
      plugins: [
        '@babel/transform-react-jsx',
        [
          'react-css-modules',
          {
            context
          }
        ]
      ]
    }
  }

but it won't work with ts-loader
Error: ts-loader was supplied with an unexpected loader option: plugins

Can you please provide example how to use it with ts?

@LuisSaybe
Copy link

would love to see an example with typescript as well

@gajus gajus added the question label Oct 29, 2019
@evenfrost
Copy link

@tomasz-szepczynski you gotta use separate babel-loader plugin to process TS before ts-loader. Here is a sample from my code:

      {
        test: /\.ts|\.tsx$/,
        use: [
          { loader: 'babel-loader' },
          { loader: 'ts-loader' },
        ],
      },

Babel plugins are specified in .babelrc in my case, but can be also set as babel-plugin options (but not the ts-loader ones).

@CKGrafico
Copy link

I'm using it in boilerplates.js.org with React and TS I hope it will help you

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

5 participants