Skip to content

About

🔨 Provide a defineConfig function for Taro project

Resources

Stars

8 stars

Watchers

1 watching

Forks

Repository files navigation

taro-define-config

Provide a defineConfig function for tarojs config

CI NPM VERSION NPM DOWNLOADS LICENSE

Important

For TaroJS v3 support, please use taro-define-config < v0.7.0.

Install

npm i taro-define-config -D
yarn add taro-define-config -D
pnpm add taro-define-config -D

Usage

// config/index.js

// @ts-check
const { defineConfig } = require('taro-define-config')

module.exports = defineConfig({
  projectName: 'hello-world',
  designWidth: 750,
})
// config/index.ts

import { defineConfig } from 'taro-define-config'

export default defineConfig({
  projectName: 'hello-world',
  designWidth: 750,
})

Why this package

Note

Taro introduced a builtin defineConfig function since v3.6.9. Maybe you don't need this package.

Improve your TaroJS project configuration experience with:

  • 🍭 more fine-grained type support than built-in defineConfig
  • 🤖 auto-suggestions
  • ✅ type checking (Use // @ts-check at the first line in your config file)
  • 📖 documentation
  • ⚠️ deprecation warnings

Extend plugin types

Plugin tuples validate options against the selected plugin name. Register third-party plugin options through module augmentation:

declare module 'taro-define-config' {
  export interface CustomPluginOptionsMap {
    'taro-plugin-custom': {
      enable?: boolean
    }
  }
}

Compiler-specific options

Platform options inherit the top-level compiler. A platform can select its own compiler explicitly:

import { defineConfig } from 'taro-define-config'

export default defineConfig({
  compiler: 'vite',
  h5: {
    legacy: true,
    devServer: { strictPort: true },
  },
  mini: {
    compiler: 'webpack5',
    output: { chunkFilename: '[name].js' },
  },
})

Prior Art

Related link

License

MIT License © 2022 to PRESENT ntnyq

About

🔨 Provide a defineConfig function for Taro project

Resources

Stars

8 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages