代码拉取完成,页面将自动刷新
import { defineConfig } from 'vite'
import reactRefresh from '@vitejs/plugin-react'
import path from 'path'
import commonjs from '@rollup/plugin-commonjs'
import typescript from '@rollup/plugin-typescript'
import config from './src/config.json'
const entries: any = {
'nutui-react.es': path.join(
__dirname,
`./src/packages/nutui.taro.react.build.ts`
),
}
const outputEntries: any = {}
config.nav.forEach((item) => {
item.packages.forEach((element) => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const { name, show, exportEmpty, exclude } = element
if (exclude) return
if (show || exportEmpty) {
outputEntries[`./${name.toLowerCase()}`] = `./${name}`
entries[name] = path.join(
__dirname,
`./src/packages/${name.toLowerCase()}/index.taro.ts`
)
}
})
})
export default defineConfig({
resolve: {
alias: [{ find: '@', replacement: path.resolve(__dirname, './src') }],
},
plugins: [reactRefresh()],
build: {
minify: false,
lib: {
entry: '',
name: 'index',
formats: ['es'],
},
rollupOptions: {
input: entries,
// 请确保外部化那些你的库中不需要的依赖
external: (id, parent) =>
/^react/.test(id) ||
/^lodash/.test(id) ||
/^async-validator/.test(id) ||
/^react-dom/.test(id) ||
/^classnames/.test(id) ||
/^@use-gesture/.test(id) ||
/^@react-spring/.test(id) ||
/^@nutui/.test(id) ||
/^@bem-react/.test(id) ||
/^@tarojs\/\w+$/.test(id) ||
(/^@\/packages\/\w+$/.test(id) && !!parent),
output: {
paths: (id) => {
return /@\/packages/.test(id)
? `${outputEntries[id.replace('@/packages/', './')]}.js`
: id
},
dir: path.resolve(__dirname, './dist/esm'),
entryFileNames: '[name].js',
chunkFileNames: '[name]-[hash].js',
},
plugins: [commonjs(), typescript()],
},
emptyOutDir: false,
},
})
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。