next.js
7e9d7cbd - Turbopack: add support for matching loaders on resource queries (#88644)

Commit
90 days ago
Turbopack: add support for matching loaders on resource queries (#88644) ### What? Part of PACK-1007 Adds `condition.query` support to Turbopack's loader rules, enabling loaders to match based on import query strings (e.g., `import './file?raw'`). This mirrors webpack's `resourceQuery` functionality. The `query` condition accepts either a string (exact match) or RegExp (pattern match). Adds tests and documentation for the new `condition.query` option. ### How to use ```js // next.config.js module.exports = { turbopack: { rules: { '*.txt': [ // String: exact match { condition: { query: '?raw' }, loaders: ['raw-loader'], as: '*.js' }, // RegExp: pattern match { condition: { query: /\?transform/ }, loaders: ['transform-loader'], as: '*.js' }, ], }, }, } ```
Author
Parents
Loading