Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Commit 3061533

Browse files
committed
Refactor library
1 parent 084cefd commit 3061533

File tree

7 files changed

+39
-18
lines changed

7 files changed

+39
-18
lines changed

dev/vue/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ import {
5454
maxLength,
5555
url,
5656
/* } from '../dist/as-dynamic-forms.common'; */
57-
} from '../src/main';
57+
} from '../../src/index';
5858
5959
const data = () => ({
6060
formData: {},

dev/vue/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Vue from 'vue';
22
import App from './App.vue';
33
import './styles/main.scss';
44

5-
import VueDynamicForms from '../../src/main'; // Dev
5+
import VueDynamicForms from '../../src/index'; // Dev
66
// import VueDynamicForms from '@asigloo/vue-dynamic-forms' // Prod
77

88
Vue.config.productionTip = false;

dev/vue/styles/_vendors.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
$input-border-radius: 50px; */
77
// @import '../../src/styles/themes/default.scss';
88

9-
@import '../../src/styles/themes/material.scss';
9+
@import '../../../src/styles/themes/material.scss';

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"scripts": {
1515
"serve": "vue-cli-service serve",
16-
"build": "vue-cli-service build --target lib --name as-dynamic-forms src/main.js",
16+
"build": "vue-cli-service build --target lib --name as-dynamic-forms src/index.js",
1717
"lint": "vue-cli-service lint",
1818
"test": "vue-cli-service test:unit --verbose --no-cache --watchAll",
1919
"publish": "npm run build && npm publish --access public",

src/index.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import DynamicForm from './components/dynamic-form/DynamicForm.vue';
2+
import DynamicInput from './components/dynamic-input/DynamicInput.vue';
3+
export * from './core/utils';
4+
const version = process.env.VERSION || require('../package.json').version;
5+
6+
export let _Vue;
7+
8+
export function install(Vue) {
9+
if (install.installed && _Vue === Vue) return;
10+
install.installed = true;
11+
12+
_Vue = Vue;
13+
14+
Vue.component('dynamic-form', DynamicForm);
15+
Vue.component('dynamic-input', DynamicInput);
16+
}
17+
18+
export const AsDynamicForms = {
19+
install,
20+
version,
21+
};
22+
23+
// Automatic installation if Vue has been added to the global scope.
24+
if (typeof window !== 'undefined' && window.Vue) {
25+
window.Vue.use(AsDynamicForms);
26+
}
27+
28+
export { DynamicForm, DynamicInput };
29+
30+
export default AsDynamicForms;

src/main.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

vue.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ module.exports = {
1717
filename: 'index.html',
1818
},
1919
},
20+
configureWebpack: {
21+
output: {
22+
libraryExport: 'default',
23+
},
24+
},
2025
chainWebpack: config => {
2126
config.optimization.splitChunks(false);
2227
config.merge({ devtool: 'source-map' });

0 commit comments

Comments
 (0)