OptionalassumptionsSet assumptions in order to produce smaller output.
OptionaldecoratorDecorator plugin
OptionaldefineReplace global variables or property accessors with the provided values.
See Oxc's define option for more details.
Replace the global variable IS_PROD with true
export default defineConfig({
transform: { define: { IS_PROD: 'true' } }
})
Result:
// Input
if (IS_PROD) {
console.log('Production mode')
}
// After bundling
if (true) {
console.log('Production mode')
}
Replace the property accessor process.env.NODE_ENV with 'production'
export default defineConfig({
transform: { define: { 'process.env.NODE_ENV': "'production'" } }
})
Result:
// Input
if (process.env.NODE_ENV === 'production') {
console.log('Production mode')
}
// After bundling
if ('production' === 'production') {
console.log('Production mode')
}
OptionaldropRemove labeled statements with these label names.
Labeled statements are JavaScript statements prefixed with a label identifier. This option allows you to strip specific labeled statements from the output, which is useful for removing debug-only code in production builds.
OptionalhelpersBehaviour for runtime helpers.
OptionalinjectInject import statements on demand.
The API is aligned with @rollup/plugin-inject.
See Oxc's inject option for more details.
{
// import { Promise } from 'es6-promise'
Promise: ['es6-promise', 'Promise'],
// import { Promise as P } from 'es6-promise'
P: ['es6-promise', 'Promise'],
// import $ from 'jquery'
$: 'jquery',
// import * as fs from 'node:fs'
fs: ['node:fs', '*'],
// Inject shims for property access pattern
'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
}
OptionaljsxControls how JSX syntax is transformed.
false, an error will be thrown if JSX syntax is encountered.'react', JSX syntax will be transformed to classic runtime React code.'react-jsx', JSX syntax will be transformed to automatic runtime React code.'preserve', JSX syntax will be preserved as-is.OptionalpluginsThird-party plugins to use.
OptionaltargetSets the target environment for the generated JavaScript.
The lowest target is es2015.
Example:
'es2015'['es2020', 'chrome58', 'edge16', 'firefox57', 'node12', 'safari11']OptionaltypescriptConfigure how TypeScript is transformed.
Construct a type with the properties of T except for those in type K.