diff --git a/build-lib.js b/build-lib.js deleted file mode 100644 index 031b500ea..000000000 --- a/build-lib.js +++ /dev/null @@ -1,105 +0,0 @@ -const fs = require('fs-extra'); -const path = require('path'); -const Service = require('@vue/cli-service/lib/Service'); -const service = new Service(process.env.VUE_CLI_CONTEXT || process.cwd()); -const _file = require("@babel/cli/lib/babel/file"); - -function buildComponent(folder, file, name) { - service.run('build', { - _: ['build', 'src/components/' + folder + '/' + file, 'build'], - modern: false, - report: false, - 'report-json': false, - 'inline-vue': false, - watch: false, - open: false, - copy: true, - https: false, - verbose: false, - target: 'lib', - clean: false, - name: name, - dest: 'dist/' + folder - }, - [ - 'build', - 'src/components/' + folder + '/' + file, - 'build', - '--target', - 'lib', - '--no-clean', - '--name', - name, - '--dest', - 'dist/' + folder - ]); -} - -function transpileJS(folder, file) { - var options = { - babelOptions: { - configFile: './.babelrc-lib' - }, - cliOptions: { - filename: undefined, - filenames: ['src/components/' + folder + '/' + file], - extensions: undefined, - keepFileExtension: undefined, - outFileExtension: undefined, - watch: undefined, - skipInitialBuild: undefined, - outFile: 'dist/' + folder + '/' + file, - outDir: undefined, - relative: undefined, - copyFiles: undefined, - copyIgnored: undefined, - includeDotfiles: undefined, - verbose: undefined, - quiet: undefined, - deleteDirOnStart: undefined, - sourceMapTarget: undefined - } - } - - _file.default(options).catch(err => { - console.error(err); - process.exitCode = 1; - }); -} - -function blue(str) { - return '\x1b[1m\x1b[34m' + str + '\x1b[39m\x1b[22m'; -} - -function green(str) { - return '\x1b[1m\x1b[32m' + str + '\x1b[39m\x1b[22m'; -} - -fs.readdirSync(path.resolve(__dirname, './src/components/')).forEach(folder => { - fs.readdirSync(path.resolve(__dirname, './src/components/' + folder)).forEach(file => { - if (!(/\.js$/.test(file)) || file === 'index.js') { - fs.copySync(path.resolve(__dirname, './src/components/' + folder) + '/' + file, 'dist/' + folder + '/' + file); - } - }); -}); - -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') { - let name = file.split(/(.vue)$|(.js)$/)[0].toLowerCase(); - if (/\.js$/.test(file)) { - console.log('Transpiling ' + blue(file)); - buildComponent(folder, file, name); - transpileJS(folder, file); - } - else if (/\.vue$/.test(file)) { - console.log('Building ' + green(name)); - buildComponent(folder, file, name); - } - } - }); -}); - -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/build-meta.js b/build-meta.js new file mode 100644 index 000000000..e2c021bea --- /dev/null +++ b/build-meta.js @@ -0,0 +1,14 @@ +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' || file.endsWith('d.ts') || file.endsWith('vue')) { + 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 2bc3d6ce9..ff59e9350 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": "NODE_ENV=production rollup -c && node build-meta && gulp build-styles", "lint": "vue-cli-service lint", "test:unit": "vue-cli-service test:unit" }, @@ -54,6 +54,9 @@ "primeicons": "4.0.0", "prismjs": "^1.15.0", "quill": "^1.3.7", + "rollup-plugin-postcss": "^4.0.0", + "rollup-plugin-terser": "^7.0.2", + "rollup-plugin-vue": "^6.0.0-beta.9", "sass-loader": "^8.0.2", "vue": "3.0.3", "vue-router": "^4.0.0-0", diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 000000000..9d6f1169c --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,121 @@ +import vue from 'rollup-plugin-vue'; +import postcss from 'rollup-plugin-postcss'; +import { terser } from 'rollup-plugin-terser'; + +const fs = require('fs-extra'); +const path = require('path'); + +let entries = []; + +let globalDependencies = { + 'vue': 'Vue', + 'primevue/ripple': 'primevue.ripple', + 'primevue/utils': 'primevue.utils', + 'primevue/button': 'primevue.button', + 'primevue/inputtext': 'primevue.inputtext', + 'primevue/dialog': 'primevue.dialog', + 'primevue/paginator': 'primevue.paginator', + 'primevue/confirmationeventbus': 'primevue.confirmationeventbus', + 'primevue/toasteventbus': 'primevue.toasteventbus', + 'primevue/useconfirm': 'primevue.useconfirm', + 'primevue/usetoast': 'primevue.usetoast', + 'primevue/progressbar': 'primevue.progressbar', + 'primevue/message': 'primevue.message', + 'primevue/dropdown': 'primevue.dropdown', + 'primevue/menu': 'primevue.menu', + '@fullcalendar/core': 'FullCalendar' +} + +function addEntry(folder, inFile, outFile) { + entries.push({ + input: 'src/components/' + folder + '/' + inFile, + output: [ + { + format: 'cjs', + file: 'dist/' + folder + '/' + outFile + '.cjs.js', + }, + { + format: 'esm', + file: 'dist/' + folder + '/' + outFile + '.esm.js' + }, + { + format: 'iife', + name: 'primevue.' + folder, + file: 'dist/' + folder + '/' + outFile + '.js', + globals: globalDependencies + } + ], + plugins: [ + vue(), + postcss() + ] + }); + + entries.push({ + input: 'src/components/' + folder + '/' + inFile, + output: [ + { + format: 'cjs', + file: 'dist/' + folder + '/' + outFile + '.cjs.min.js' + }, + { + format: 'esm', + file: 'dist/' + folder + '/' + outFile + '.esm.min.js' + }, + { + format: 'iife', + name: folder, + file: 'dist/' + folder + '/' + outFile + '.min.js', + globals: globalDependencies + } + ], + plugins: [ + vue(), + postcss(), + terser() + ] + }); +} + +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) && (name === folder)) { + 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('useconfirm', 'UseConfirm.js', 'useconfirm'); + addEntry('toastservice', 'ToastService.js', 'toastservice'); + addEntry('toasteventbus', 'ToastEventBus.js', 'toasteventbus'); + addEntry('usetoast', 'UseToast.js', 'usetoast'); + addEntry('terminalservice', 'TerminalService.js', 'terminalservice'); +} + +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 @@ diff --git a/src/components/paginator/PrevPageLink.vue b/src/components/paginator/PrevPageLink.vue index 88d56b110..232c4fa60 100755 --- a/src/components/paginator/PrevPageLink.vue +++ b/src/components/paginator/PrevPageLink.vue @@ -5,7 +5,7 @@ diff --git a/src/views/invalid/InvalidDemo.vue b/src/views/invalid/InvalidDemo.vue index 9ded5bf81..cb1191a59 100644 --- a/src/views/invalid/InvalidDemo.vue +++ b/src/views/invalid/InvalidDemo.vue @@ -126,7 +126,7 @@ export default { } }, 250); } - }, + } } @@ -182,7 +182,7 @@ export default { } }, 250); } - }, + } } diff --git a/src/views/liveeditor/LiveEditor.vue b/src/views/liveeditor/LiveEditor.vue index e582b69e2..60f70619a 100644 --- a/src/views/liveeditor/LiveEditor.vue +++ b/src/views/liveeditor/LiveEditor.vue @@ -1,5 +1,5 @@ @@ -45,7 +45,7 @@ export default { activeButtonIndex: { type: String, default: null - }, + } }, methods: { postSandboxParameters() { @@ -511,6 +511,11 @@ ${services[this.service]} return this.createSandboxParameters(`${name}${extension}`, _files, extDependencies); } + }, + computed: { + showEditor() { + return this.$appState.codeSandbox; + } } } \ No newline at end of file diff --git a/src/views/liveeditor/LiveEditorData.js b/src/views/liveeditor/LiveEditorData.js index 877f2894f..5661d82d9 100644 --- a/src/views/liveeditor/LiveEditorData.js +++ b/src/views/liveeditor/LiveEditorData.js @@ -4274,7 +4274,7 @@ const data = { {"id": "1009","code": "cm230f032","name": "Gaming Set","description": "Product Description","image": "gaming-set.jpg","price": 299,"category": "Electronics","quantity": 63,"inventoryStatus": "INSTOCK","rating": 3,"orders": [{"id": "10000","productCode": "cm230f032","date": "2020-06-24","amount": 299,"quantity": 1,"customer": "Kadeem Mujtaba","status": "PENDING"},{"id": "10001","productCode": "cm230f032","date": "2020-05-11","amount": 299,"quantity": 1,"customer": "Ashley Wickens","status": "DELIVERED"},{"id": "10002","productCode": "cm230f032","date": "2019-02-07","amount": 299,"quantity": 1,"customer": "Julie Johnson","status": "DELIVERED"},{"id": "10003","productCode": "cm230f032","date": "2020-04-26","amount": 299,"quantity": 1,"customer": "Tony Costa","status": "CANCELLED"}]} ] } - `, + ` } export { services, data }; diff --git a/src/views/steps/ConfirmationDemo.vue b/src/views/steps/ConfirmationDemo.vue index b05b8d764..8a0fb1b24 100755 --- a/src/views/steps/ConfirmationDemo.vue +++ b/src/views/steps/ConfirmationDemo.vue @@ -64,6 +64,6 @@ export default { complete() { this.$emit('complete'); } - }, + } } \ No newline at end of file diff --git a/src/views/steps/StepsDoc.vue b/src/views/steps/StepsDoc.vue index 0ffb0731f..34cf8fdc0 100755 --- a/src/views/steps/StepsDoc.vue +++ b/src/views/steps/StepsDoc.vue @@ -495,7 +495,7 @@ export default { complete() { this.$emit('complete'); } - }, + } } diff --git a/src/views/terminal/TerminalDemo.vue b/src/views/terminal/TerminalDemo.vue index 17e73631b..3bf75eee0 100755 --- a/src/views/terminal/TerminalDemo.vue +++ b/src/views/terminal/TerminalDemo.vue @@ -20,7 +20,7 @@