代码拉取完成,页面将自动刷新
同步操作将从 antv/X6 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import fs from 'fs'
import path from 'path'
import _ from 'lodash'
import colors from 'colors/safe.js'
import terser from '@rollup/plugin-terser'
import replace from '@rollup/plugin-replace'
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import filesize from 'rollup-plugin-filesize'
import typescript from '@rollup/plugin-typescript'
function formatName(name) {
const realName = name
.replace(/^@/, '')
.replace(/^antv\//, '')
.replace(/\//, '-')
// PascalCase
return _.startCase(_.camelCase(realName)).replace(/ /g, '')
}
function makeOutput() {
const cwd = process.cwd()
const pkg = JSON.parse(
fs.readFileSync(path.join(cwd, 'package.json'), 'utf8'),
)
const peerDependencies = pkg.peerDependencies
const output = { name: formatName(pkg.name) }
if (peerDependencies) {
const globals = {}
Object.keys(peerDependencies).forEach((mod) => {
globals[mod] = formatName(mod)
})
output.globals = globals
}
return output
}
export function config(config = {}) {
let { plugins = [], output, external = [], ...others } = config
if (output == null) {
output = makeOutput()
}
const arr = Array.isArray(output) ? output : [output]
const outputs = []
arr.forEach((item) => {
outputs.push({
format: 'umd',
file: 'dist/index.js',
sourcemap: true,
...item,
})
// extra external modules
if (item.globals) {
Object.keys(item.globals).forEach((key) => {
if (!external.includes(key)) {
external.push(key)
}
})
}
})
return {
input: './src/index.ts',
output: outputs,
plugins: [
typescript({ declaration: false }),
resolve(),
commonjs(),
replace({
preventAssignment: true,
'process.env.NODE_ENV': JSON.stringify('production'),
}),
terser({ sourceMap: true }),
filesize({
reporter: [
async (options, bundle, result) => {
return import('boxen').then((mod) => {
const boxen = mod.default
const primaryColor = options.theme === 'dark' ? 'green' : 'black'
const secondaryColor =
options.theme === 'dark' ? 'yellow' : 'blue'
const title = colors[primaryColor].bold
const value = colors[secondaryColor]
const lines = [
`${title('Bundle Format:')} ${value(bundle.format)}`,
`${title('Bundle Name:')} ${value(bundle.name)}`,
]
const globals = bundle.globals
const mods = Object.keys(globals)
if (mods.length) {
lines.push(title('External Globals:'))
mods.forEach((mod) => {
lines.push(value(` ${mod}: ${globals[mod]}`))
})
lines.push('')
}
lines.push(
[
`${title('Destination:')} ${value(bundle.file)}`,
`${title('Bundle Size:')} ${value(result.bundleSize)}`,
`${title('Minified Size:')} ${value(result.minSize)}`,
`${title('Gzipped Size:')} ${value(result.gzipSize)}`,
].join('\n'),
)
return boxen(lines.join('\n'), {
padding: 1,
dimBorder: true,
borderStyle: 'classic',
})
})
},
],
}),
...plugins,
],
external,
...others,
}
}
const defaultConfig = config()
export default defaultConfig
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。