import fs from 'fs';
import path from 'path';
import babel from 'rollup-plugin-babel';
import vue from 'rollup-plugin-vue';
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import tailwindcss from 'tailwindcss';
import postcss from 'rollup-plugin-postcss';
const babelConfig = babel({
exclude: /node_modules/,
runtimeHelpers: true,
babelrc: false,
presets: [
[
'@babel/preset-env', {
modules: false
}
]
],
});
const vueConfig = vue({
css: false,
style: {
postcssPlugins: [tailwindcss()]
},
// template: {
// isProduction: true
// }
});
const baseFolder = './src/';
const components = fs.readdirSync(baseFolder)
.filter(f => fs.statSync(path.join(baseFolder, f)).isDirectory());
const entries = {
index: './src/index.js',
...components.reduce((obj, name) => {
obj[name] = (baseFolder + name + '/index.js')
return obj
}, {})
};
export default {
input: entries,
output: [
{
dir: 'lib/esm/',
format: 'esm',
},
],
external: ['vue'],
plugins: [
resolve({
extensions: ['.vue', '.js', '.css']
}),
postcss({
extract: true,
extract: path.resolve('lib/esm/lib.css'),
plugins: [tailwindcss()]
}),
babelConfig,
vueConfig,
commonjs(),
],
};