代码拉取完成,页面将自动刷新
同步操作将从 京东零售/nutui 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';
import vue from '@vitejs/plugin-vue';
import path from 'path';
const fs = require('fs-extra');
import config from './package.json';
import configPkg from './src/config.json';
import { terser } from 'rollup-plugin-terser';
const banner = `/*!
* ${config.name} v${config.version} ${new Date()}
* (c) 2022 @jdf2e.
* Released under the MIT License.
*/`;
let input = {};
configPkg.nav.map((item) => {
item.packages.forEach((element) => {
let { name } = element;
const filePath = path.join(`./src/packages/__VUE/${name.toLowerCase()}/index.taro.vue`);
input[name] = `./src/packages/__VUE/${name.toLowerCase()}/index${fs.existsSync(filePath) ? '.taro' : ''}.vue`;
});
});
export default defineConfig({
resolve: {
alias: [{ find: '@', replacement: path.resolve(__dirname, './src') }]
},
plugins: [
vue(),
dts({
insertTypesEntry: true,
copyDtsFiles: false,
cleanVueFileName: false,
outputDir: path.resolve(__dirname, './dist/types'),
include: path.resolve(__dirname, './src/packages/__VUE'),
beforeWriteFile: (filePath: string, content: string) => {
const fileContent = `import { App, PropType, CSSProperties } from 'vue';
declare type Install<T> = T & {
install(app: App): void;
};
`;
const start = 'declare const _sfc_main:';
const end = ';\nexport default _sfc_main;\n';
let name = Object.keys(input).find((item: string) => item.toLowerCase() === filePath.split('/').slice(-2)[0]);
name = name ? name.toLowerCase() : ' ';
const remain = `
declare module 'vue' {
interface GlobalComponents {
Nut${name[0].toUpperCase() + name.substr(1)}: typeof _sfc_main;
}
}
`;
const inputs = content.match(RegExp(`${start}([\\s\\S]*?)${end}`));
const changeContent = inputs && inputs.length ? `${start} Install<${inputs[1]}>${end}${remain}` : content;
return {
filePath,
content: fileContent + changeContent
};
}
})
],
build: {
minify: false,
lib: {
entry: '',
name: 'index',
// fileName: (format) => format,
formats: ['es']
},
rollupOptions: {
// 请确保外部化那些你的库中不需要的依赖
external: ['vue', 'vue-router', '@tarojs/taro', '@/packages/locale'],
input,
output: {
banner,
paths: {
'@/packages/locale': '../locale/lang'
},
dir: path.resolve(__dirname, './dist/packages/_es'),
entryFileNames: '[name].js',
plugins: [
terser({
compress: {
drop_console: true,
drop_debugger: true
}
})
]
}
},
emptyOutDir: false
}
});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。