next.js
99eae38f - Turbopack: add `rules.*.type` config to allow changing the type of a module (#88788)

Commit
46 days ago
Turbopack: add `rules.*.type` config to allow changing the type of a module (#88788) ### What? This PR adds support for the `type` option in Turbopack rules, enabling users to set the module type directly without requiring a custom loader. This mirrors webpack's [`type`](https://webpack.js.org/configuration/module/#ruletype) option (e.g., `type: 'asset/resource'`). Users can now configure how files are processed by setting the module type directly: ```js // next.config.js module.exports = { turbopack: { rules: { '*.svg': { type: 'asset', }, }, }, } ``` When using type: 'asset', importing the file returns its URL: ``` import svgUrl from './icon.svg' export default function Page() { return <img src={svgUrl} alt="Icon" /> } ``` More types are available. See docs
Author
Parents
Loading