1 Star 0 Fork 0

jia/lowcode4

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
vite.config.ts 2.64 KB
一键复制 编辑 原始数据 按行查看 历史
jiafuhui 提交于 2023-11-22 16:02 . feat: 完成
import VitePluginStyleInject from 'vite-plugin-style-inject';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import type { Plugin, ResolvedConfig } from 'vite';
import cleaner from 'rollup-plugin-cleaner';
import react from '@vitejs/plugin-react';
import url from '@rollup/plugin-url';
import { defineConfig } from 'vite';
import svgr from '@svgr/rollup';
import { exec } from 'child_process';
const globalName = 'emailEditor';
const output = './src/index.ts';
function consoleConfig(): Plugin {
return {
name: 'consoleConfig',
apply: 'serve',
enforce: "post",
configResolved(resolvedConfig: ResolvedConfig) {
console.log('resolvedConfig', resolvedConfig);
},
}
}
function dts(): Plugin {
return {
name: 'dts',
apply: 'build',
enforce: "post",
configResolved(resolvedConfig: ResolvedConfig) {
console.log('resolvedConfig', resolvedConfig);
},
generateBundle() {
// console.log("{{{{{ ------ generateBundle");
},
buildEnd() {
console.log(" ------ buildEnd ------ ");
exec(`tsc -p ${process.cwd()}/tsconfig.json`)
}
}
}
// https://vitejs.dev/config/
const config = defineConfig(({ command, mode }) => {
if (command === 'serve') {
return {
plugins: [
react(),
url(),
svgr({ icon: true }),
consoleConfig(),
],
}
}
return {
build: {
cssCodeSplit: true,
minify: false,
lib: {
entry: output,
fileName: (format, entryName) => {
console.log('----fileName', format, entryName);
return `${entryName}.js`
}
},
rollupOptions: {
input: output,
external: ['react-dom', 'react', 'react/jsx-runtime'],
output: [
{
dir: 'lib/es',
format: 'es',
preserveModules: true,
},
{
dir: 'lib/cjs',
format: 'cjs',
preserveModules: true,
exports: 'named',
},
{
dir: 'lib/umd',
format: 'umd',
name: globalName,
exports: 'named',
globals: {
react: 'React',
'react-dom': 'ReactDOM',
'react/jsx-runtime': 'jsxRuntime'
}
},
],
preserveEntrySignatures: 'strict',
},
},
plugins: [
cleaner({
targets: ['./lib']
}),
nodeResolve({
browser: true,
}),
react({
jsxRuntime: 'classic',
}),
VitePluginStyleInject(),
url(),
svgr({ icon: true }),
dts(),
],
}
})
export default config
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jia-code/lowcode4.git
[email protected]:jia-code/lowcode4.git
jia-code
lowcode4
lowcode4
master

搜索帮助