Skip to content
Docs
/
Usage
/
swc-loader

swc-loader

This module allows you to use SWC with webpack.

Installation

npm i --save-dev @swc/core swc-loader

Usage

module: {
  rules: [
    {
      test: /\.m?js$/,
      exclude: /(node_modules)/,
      use: {
        // `.swcrc` can be used to configure swc
        loader: "swc-loader"
      }
    }
  ]
}

React Development

The jsc.transform.react.development option is automatically set based on the webpack mode.

With babel-loader

When used with babel-loader, the parseMap option must be set to true.

module: {
  rules: [
    {
      test: /\.m?js$/,
      exclude: /(node_modules)/,
      use: {
        loader: "swc-loader",
        options: {
          parseMap: true
        }
      }
    }
  ]
}
Last updated on June 22, 2022