tools.lightningcssLoader

  • Type: Rspack.LightningcssLoaderOptions | Function | boolean
  • Default:
const defaultOptions = {
  // use current browserslist config
  targets: browserslist,
  // minify is enabled when output.injectStyles is true and in production mode
  minify: config.mode === 'production' && config.output.injectStyles,
};
  • Version: >= 1.0.0

You can set the options for builtin:lightningcss-loader through tools.lightningcssLoader.

Object Type

When tools.lightningcssLoader is an object, it will be merged with the default configuration using Object.assign.

For example, you can disable the addition of vendor prefixes through tools.lightningcssLoader.exclude. In this case, you can use PostCSS's autoprefixer plugin to add vendor prefixes.

export default {
  tools: {
    lightningcssLoader: {
      exclude: {
        vendorPrefixes: false,
      },
    },
  },
};

Function Type

When tools.lightningcssLoader is a function, the default options will be passed in as the first parameter. You can directly modify this object or return a new object as the final options to be used. For example:

export default {
  tools: {
    lightningcssLoader: (config) => {
      config.exclude = {
        vendorPrefixes: false,
      };
      return config;
    },
  },
};

Disable loader

Set tools.lightningcssLoader to false to disable the built-in lightningcss-loader in Rsbuild:

export default {
  tools: {
    lightningcssLoader: false,
  },
};