代码拉取完成,页面将自动刷新
同步操作将从 簡 Kan/lunisolar 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import fs from 'fs'
import path from 'path'
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import ts from 'rollup-plugin-typescript2'
import terser from '@rollup/plugin-terser'
import copy from 'rollup-plugin-copy'
import clear from 'rollup-plugin-clear'
import pkg from './package.json'
import dts from 'rollup-plugin-dts'
import filesize from 'rollup-plugin-filesize'
const extensions = ['.js', '.jsx', '.ts', '.tsx']
const upCaseFirst = str => (str[0] ? str[0].toUpperCase() + str.slice(1) : '')
const formatName = n => {
return n
.trim()
.replace(/\.(js|ts)$/, '')
.split('-')
.map((v, i) => (i === 0 ? v.trim() : upCaseFirst(v.trim())))
.join('')
}
// plugins
const tsPlugin = ts({ extensions })
const terserPlugin = terser()
const dtsPlugin = dts()
// fileName: pkg.module,
const configFactory = config => {
const { input, fileName, filePath, name, isClear, createEs, copyFile, pluginsPush } = config
// load rollup plugins
const plugins = [resolve(), commonjs(), tsPlugin, terserPlugin, filesize()]
if (isClear) plugins.unshift(clear({ targets: ['dist', 'plugins', 'locale', 'markers'] }))
if (copyFile) plugins.push(copy(copyFile))
if (pluginsPush) {
plugins.push(...pluginsPush)
}
// output
const output = [
{
// UMD for browser-friendly build
name: name || 'lunisolar',
file: filePath && fileName ? path.join(filePath, `${fileName}.js`) : pkg.main,
format: 'umd'
}
]
if (createEs) {
output.push({
// ES module for bundlers build
file: fileName ? path.join(filePath, `${fileName}.esm.js`) : pkg.module,
format: 'es'
})
}
return {
input,
output,
plugins
}
}
const configs = [
configFactory({
input: 'src/index.ts',
isClear: true,
createEs: true,
copyFile: {
targets: [
{
src: 'typings/plugins/**/*',
dest: 'plugins'
}
]
}
})
]
// 对指定dir打包的配置
const configDir = (dir, config) => {
const dirPath = path.join(__dirname, 'src', dir)
const dirNames = fs.readdirSync(dirPath)
const namePrefix = config?.namePrefix ?? null
const inputName = config?.inputName ?? ''
const useDts = config?.useDts ?? false
for (const dirName of dirNames) {
const fixDirName = namePrefix ? namePrefix + upCaseFirst(dirName) : dirName
const input = path.join(dirPath, dirName, inputName)
const filePath = path.join(__dirname, dir)
const fileName = dirName.replace(/\.(js|ts)$/, '')
const config = configFactory({
name: formatName(fixDirName),
input,
filePath,
fileName
})
configs.push(config)
if (useDts) {
configs.push({
input,
output: {
file: path.join(filePath, `${fileName}.d.ts`),
format: 'es'
},
plugins: [dtsPlugin]
})
}
}
}
// 对插件语言包进行打包的配置
const configPluginLocaleDir = () => {
const dirPath = path.join(__dirname, 'src', 'plugins')
const dirNames = fs.readdirSync(dirPath)
for (const dirName of dirNames) {
const localePath = path.join(dirPath, dirName, 'locale')
const localeNames = fs.readdirSync(localePath)
for (const localeName of localeNames) {
const filePath = path.join(__dirname, 'plugins', dirName, 'locale')
const fileName = localeName.replace(/\.(js|ts)$/, '')
const config = configFactory({
name: dirName + '_' + formatName(localeName),
input: path.join(localePath, localeName),
filePath,
fileName
})
configs.push(config)
configs.push({
input: path.join(localePath, localeName),
output: {
file: path.join(filePath, `${fileName}.d.ts`),
format: 'es'
},
plugins: [dtsPlugin]
})
}
}
}
configDir('plugins', { namePrefix: 'lunisolarPlugin', inputName: 'index.ts' })
configDir('locale', { namePrefix: 'lunisolarLocale' })
configDir('markers', { namePrefix: 'lunisolarMarkers', useDts: true })
configPluginLocaleDir()
export default configs
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。