代码拉取完成,页面将自动刷新
同步操作将从 hiisea/elux-fork 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/* eslint-disable no-console */
import path from 'path';
import * as fs from 'fs';
import babel from '@rollup/plugin-babel';
import chalk from 'chalk';
import commonjs from '@rollup/plugin-commonjs';
import replace from '@rollup/plugin-replace';
import resolve from '@rollup/plugin-node-resolve';
import alias from '@rollup/plugin-alias';
const tag = process.env.NODE_TAG || process.env.NODE_ENV;
function createConfig(fileName = 'index', inputFile, externals, aliasEntries) {
const outputFile = inputFile.replace('src/', '');
const cfg = {
es6: {output: [{file: `dist/es6/${outputFile}${fileName}.js`, format: 'esm'}], mainFields: ['module', 'main']},
es5: {
output: [
{file: `dist/es5/${outputFile}${fileName}.js`, format: 'esm'},
//{file: `dist/cjs/${outputFile}${fileName}.js`, format: 'cjs'},
],
mainFields: ['main', 'module'],
},
};
const env = cfg[tag];
const extensions = ['.js', '.ts', '.tsx'];
const pkgResult = {include: {}, external: {}};
const config = {
input: inputFile,
output: env.output,
external: (id) => {
const hit = externals.some((mod) => mod === id || id.startsWith(`${mod}/`));
if (hit) {
if (!pkgResult.external[id]) {
pkgResult.external[id] = true;
console.warn(chalk.red('external: '), id);
}
} else if (!pkgResult.include[id]) {
pkgResult.include[id] = true;
console.warn(chalk.green('include: '), id);
}
return hit;
},
plugins: [
aliasEntries &&
alias({
entries: aliasEntries,
}),
process.env.NODE_ENV === 'production' && replace({'process.env.NODE_ENV': '"production"'}),
resolve({extensions, mainFields: env.mainFields}),
babel({
exclude: 'node_modules/**',
extensions,
babelHelpers: 'runtime',
skipPreflightCheck: true,
// externalHelpers: true,
}),
commonjs(),
].filter(Boolean),
};
return config;
}
export default function (root, aliasEntries) {
const inputFiles = ['src/'];
const libsDir = path.resolve(root, './src/lib/');
if (fs.existsSync(libsDir)) {
const libs = fs.readdirSync(libsDir);
libs.forEach((item) => {
inputFiles.push(`src/lib/${item}/`);
});
}
console.log(inputFiles);
const pkg = require(path.resolve(root, './package.json'));
const externals = Object.keys(pkg.externals ? pkg.externals : {...pkg.dependencies, ...pkg.peerDependencies});
return inputFiles.map((bundle) => createConfig(undefined, bundle, externals, aliasEntries));
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。