diff --git a/build-meta.js b/build-meta.js new file mode 100644 index 000000000..433130666 --- /dev/null +++ b/build-meta.js @@ -0,0 +1,19 @@ +const fs = require('fs-extra'); +const path = require('path'); + +fs.readdirSync(path.resolve(__dirname, './src/components/')).forEach(folder => { + fs.readdirSync(path.resolve(__dirname, './src/components/' + folder)).forEach(file => { + if (file ==='package.json') { + fs.copySync(path.resolve(__dirname, './src/components/' + folder) + '/package.json', 'dist/' + folder + '/package.json'); + } + + if (file.endsWith('d.ts')) { + fs.copySync(path.resolve(__dirname, './src/components/' + folder) + '/' + file, 'dist/' + folder + '/' + file); + } + }) + +}); + +fs.copySync(path.resolve(__dirname, './package-build.json'), 'dist/package.json'); +fs.copySync(path.resolve(__dirname, './README.md'), 'dist/README.md'); +fs.copySync(path.resolve(__dirname, './LICENSE.md'), 'dist/LICENSE.md'); \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 8928c950f..77249d62e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -33,5 +33,5 @@ gulp.task('images', function() { }); //Building project with run sequence -gulp.task('build-resources', ['build-css', 'images', 'build-themes']); +gulp.task('build-styles', ['build-css', 'images', 'build-themes']); diff --git a/package.json b/package.json index 096d31a3c..414ab4096 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "scripts": { "serve": "vue-cli-service serve", "build-app": "vue-cli-service build", - "build-lib": "node build-lib && gulp build-resources", + "build-lib": "rollup -c && node build-meta && gulp build-styles", "lint": "vue-cli-service lint", "test:unit": "vue-cli-service test:unit" }, diff --git a/rollup.config.js b/rollup.config.js index dd38df094..1ed44d970 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -6,33 +6,67 @@ const path = require('path'); let entries = []; -fs.readdirSync(path.resolve(__dirname, './src/components/')).forEach(folder => { - fs.readdirSync(path.resolve(__dirname, './src/components/' + folder)).forEach(file => { - if (file !== 'index.js' && file !== 'index.d.ts') { +function addEntry(folder, inFile, outFile) { + entries.push({ + input: 'src/components/' + folder + '/' + inFile, + output: [ + { + format: 'esm', + file: 'dist/' + folder + '/' + outFile + '.esm.js' + }, + { + format: 'cjs', + file: 'dist/' + folder + '/' + outFile + '.cjs.js' + }, + { + format: 'umd', + name: 'primevue', + file: 'dist/' + folder + '/' + outFile + '.umd.js' + } + ], + plugins: [ + vue(), + postcss() + ] + }); +} + +function addSFC() { + fs.readdirSync(path.resolve(__dirname, './src/components/')).forEach(folder => { + fs.readdirSync(path.resolve(__dirname, './src/components/' + folder)).forEach(file => { let name = file.split(/(.vue)$|(.js)$/)[0].toLowerCase(); if (/\.vue$/.test(file)) { - entries.push({ - input: 'src/components/' + folder + '/' + file, - external: [/\.\./], - output: [ - { - format: 'esm', - file: 'dist/' + folder + '/' + name + '.esm.js' - }, - { - format: 'umd', - name: 'primevue', - file: 'dist/' + folder + '/' + name + '.umd.js' - } - ], - plugins: [ - vue(), - postcss() - ] - }); + addEntry(folder, file, name); } - } + }); }); -}); +} + +function addDirectives() { + addEntry('badgedirective', 'BadgeDirective.js', 'badgedirective'); + addEntry('ripple', 'Ripple.js', 'ripple'); + addEntry('tooltip', 'Tooltip.js', 'tooltip'); +} + +function addConfig() { + addEntry('config', 'PrimeVue.js', 'config'); +} + +function addUtils() { + addEntry('utils', 'Utils.js', 'utils'); +} + +function addServices() { + addEntry('confirmationservice', 'ConfirmationService.js', 'confirmationservice'); + addEntry('confirmationeventbus', 'ConfirmationEventBus.js', 'confirmationeventbus'); + addEntry('toastservice', 'ToastService.js', 'toastservice'); + addEntry('toasteventbus', 'ToastEventBus.js', 'toasteventbus'); +} + +addSFC(); +addDirectives(); +addConfig(); +addUtils(); +addServices(); export default entries; \ No newline at end of file diff --git a/src/components/accordion/Accordion.vue b/src/components/accordion/Accordion.vue index 7746830d5..ceaf5e761 100755 --- a/src/components/accordion/Accordion.vue +++ b/src/components/accordion/Accordion.vue @@ -22,7 +22,7 @@