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

Commit 1daf8de

Browse files
author
Steffan
committed
add version, update deps
1 parent e427470 commit 1daf8de

File tree

5 files changed

+365
-249
lines changed

5 files changed

+365
-249
lines changed

build/build.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const rollup = require('rollup');
66
const uglify = require('uglify-js');
77
const vue = require('rollup-plugin-vue');
88
const buble = require('rollup-plugin-buble');
9+
const replace = require('rollup-plugin-replace');
910
const {name, version, homepage} = require('../package.json');
1011
const banner =
1112
'/*!\n' +
@@ -16,7 +17,7 @@ const banner =
1617

1718
rollup.rollup({
1819
input: 'src/index.js',
19-
plugins: [vue(), buble()]
20+
plugins: [vue(), buble(), replace({__VERSION__: version})]
2021
})
2122
.then(bundle =>
2223
bundle.generate({

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@
3535
"eslint": "^5.1.0",
3636
"eslint-plugin-vue": "^4.7.0",
3737
"replace-in-file": "^3.1.1",
38-
"rollup": "^0.63.2",
38+
"rollup": "^0.64.1",
3939
"rollup-plugin-buble": "^0.19.1",
40+
"rollup-plugin-replace": "^2.0.0",
4041
"rollup-plugin-vue": "^3.0.0",
4142
"uglify-js": "^3.4.5",
4243
"vue": "^2.5.17",

src/index.js

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,32 @@
22
* Install plugin.
33
*/
44

5-
import Util from './util';
65
import Field from './field';
76
import Fields from './fields.vue';
7+
import Util, {log} from './util';
88

9-
export default function plugin(Vue) {
9+
const Plugin = {
1010

11-
if (plugin.installed) {
12-
return;
13-
}
11+
Field,
12+
Fields,
1413

15-
Util(Vue);
14+
install(Vue) {
1615

17-
Vue.component('field', Field);
18-
Vue.component('fields', Fields);
19-
}
16+
if (this.installed) {
17+
return;
18+
}
19+
20+
Util(Vue); log(this.version);
2021

21-
plugin.Field = Field;
22-
plugin.Fields = Fields;
22+
Vue.component('field', Field);
23+
Vue.component('fields', Fields);
24+
},
25+
26+
version: '__VERSION__'
27+
};
2328

2429
if (typeof window !== 'undefined' && window.Vue) {
25-
window.Vue.use(plugin);
30+
window.Vue.use(Plugin);
2631
}
32+
33+
export default Plugin;

src/util.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,27 @@
22
* Utility functions.
33
*/
44

5-
let debug = false, _set;
5+
let _config = {}, _set;
66

77
export const assign = Object.assign || _assign;
88

99
export const isArray = Array.isArray;
1010

1111
export default function ({set, config}) {
1212
_set = set;
13-
debug = config.debug || !config.silent;
13+
_config = config;
1414
}
1515

16-
export function warn(msg) {
17-
if (typeof console !== 'undefined' && debug) {
18-
console.log(`%c vue-fields %c ${msg} `, 'color: #fff; background: #35495E; padding: 1px; border-radius: 3px 0 0 3px;', 'color: #fff; background: #DB6B00; padding: 1px; border-radius: 0 3px 3px 0;');
16+
export function log(message, color = '#41B883') {
17+
if (typeof console !== 'undefined' && _config.devtools) {
18+
console.log(`%c vue-fields %c ${message} `, 'color: #fff; background: #35495E; padding: 1px; border-radius: 3px 0 0 3px;', `color: #fff; background: ${color}; padding: 1px; border-radius: 0 3px 3px 0;`);
1919
}
2020
}
2121

22+
export function warn(message, color = '#DB6B00') {
23+
log(message, color);
24+
}
25+
2226
export function isString(val) {
2327
return typeof val === 'string';
2428
}

0 commit comments

Comments
 (0)