ui-lib/vite.build.js
2024-01-25 14:56:31 +08:00

45 lines
960 B
JavaScript

import { build } from "vite";
import postcssPresetEnv from "postcss-preset-env";
import { viteExternalsPlugin } from "vite-plugin-externals";
const libraries = [
{
clearScreen: false,
css: {
postcss: {
plugins: [postcssPresetEnv()]
}
},
build: {
lib: {
entry: './lib/ui.js',
name: 'lib-ui',
formats: ['umd'],
fileName: (_format, name) => `${name}.min.js`
},
rollupOptions: {
output: {
assetFileNames: info => info.name === 'style.css' ? 'ui.min.css' : info.name
}
},
sourcemap: true,
emptyOutDir: false
}
},
{
clearScreen: false,
build: {
lib: {
entry: './lib/utility.js',
name: 'lib-utility',
formats: ['umd'],
fileName: (_format, name) => `${name}.min.js`
},
sourcemap: true,
emptyOutDir: false
}
}
]
libraries.forEach(async b => await build(b))