Docs
Configuration
Babel

Babel Support

Lark CLI default supported *** babel *** configurations are:

//...
let environment = []
 
if ((BABEL_ENV || NODE_ENV) === 'development') {
  environment = [
    shouldUseReactRefresh && require.resolve('react-refresh/babel'),
    ['@babel/plugin-syntax-dynamic-import'],
    ...(shouldUseMFSURefresh ? mfsu.getBabelPlugins() : [])
  ].filter(Boolean)
} else {
  environment = [
    '@babel/plugin-syntax-dynamic-import',
    'babel-plugin-transform-react-remove-prop-types',
    '@babel/plugin-transform-react-constant-elements'
  ]
}
const config = {
  presets: [
    '@babel/preset-env',
    '@babel/preset-typescript',
    '@babel/preset-react'
  ],
  plugins: [
    ...environment,
    ['babel-plugin-module-resolver', resolverOpts],
    '@babel/plugin-proposal-object-rest-spread',
    ['@babel/plugin-proposal-decorators', { legacy: true }],
    '@babel/plugin-proposal-class-properties',
    'babel-plugin-macros',
    '@babel/plugin-transform-runtime'
  ]
}
//...

Babel Custom

You can create babel.config.js in the project root directory by yourself, *** Lark CLI *** will read the configuration file by default, no difference from the babel configuration file

Demo:

babel.config.js
module.exports = (api) => {
  return {
    plugins: []
  }
}
 

Override default babel configuration

Override *** Lark CLI *** Default babel configuration, overridden by passing in field overrides

Demo:

babel.config.js
module.exports = (api) => {
  return {
    overrides: true,
    presets: [
      '@babel/preset-env',
      '@babel/preset-typescript',
      '@babel/preset-react'
    ],
    plugins: [
      ['babel-plugin-module-resolver', resolverOpts],
      '@babel/plugin-proposal-object-rest-spread',
      ['@babel/plugin-proposal-decorators', { legacy: true }],
      '@babel/plugin-proposal-class-properties',
      'babel-plugin-macros',
      '@babel/plugin-transform-runtime'
    ]
  }
}
 

Other

lark.config.js
module.exports = {
  build: {
    mfsu: false,
    transpiler: 'babel',
    transpilerOptions: {},
  },
}