Home > @lynx-js/react-webpack-plugin > ReactWebpackPlugin > loaders

ReactWebpackPlugin.loaders property

The loaders for ReactLynx.

Signature:

static loaders: Record<keyof typeof LAYERS, string>;

Remarks

Note that this loader will only transform JSX/TSX to valid JavaScript. For .tsx files, the type annotations would not be eliminated. You should use babel-loader or swc-loader to load TypeScript files.

Example

// webpack.config.js
import { ReactWebpackPlugin, LAYERS } from '@lynx-js/react-webpack-plugin'
export default {
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        layer: LAYERS.MAIN_THREAD,
        use: ['swc-loader', ReactWebpackPlugin.loaders.MAIN_THREAD]
      },
      {
        test: /\.tsx?$/,
        layer: LAYERS.BACKGROUND,
        use: ['swc-loader', ReactWebpackPlugin.loaders.BACKGROUND]
      },
    ],
  },
  plugins: [new ReactWebpackPlugin()],
}