string | Record<BuilderTarget, string>
undefined
Add a prefix to resolve.extensions.
If multiple files share the same name but have different extensions, Modern.js will resolve the one with the extension listed first in the array and skip the rest.
With the configuration above, the extensions array will become:
When import './foo'
in the code, the foo.web.js
file will be resolved first, then the foo.js
file.
When you build multiple targets at the same time, you can set different extension prefix for different targets. At this point, you need to set resolveExtensionPrefix
to an object whose key is the corresponding build target.
For example to set different extension prefix for web
and node
:
When import './foo'
in the code, the foo.node.js
file will be resolved for node target, and the foo.web.js
file will be resolved for web target.