Skip to content

Commit 299a213

Browse files
committed
chore: update
1 parent fb90d74 commit 299a213

File tree

13 files changed

+148
-39
lines changed

13 files changed

+148
-39
lines changed

balm.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const getConfig = require('./config/balmrc');
2-
const api = require('./config/balm.api');
1+
const getConfig = require('./config/balm');
2+
const api = require('./config/balm/api');
33

44
module.exports = (balm) => {
55
return {

config/balm.api.js

-6
This file was deleted.

config/balm/api.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const env = require('../env');
2+
const buildIndividual = require('../build/individual');
3+
const buildESModule = require('../build/esm');
4+
5+
module.exports = (mix) => {
6+
if (env.buildDocs) {
7+
} else {
8+
if (mix.env.isProd) {
9+
buildIndividual(mix);
10+
buildESModule(mix);
11+
} else {
12+
mix.copy('node_modules/balm-ui/fonts/*', 'docs/fonts');
13+
}
14+
}
15+
};

config/balm/env.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const buildDocs = process.argv.includes('--docs');
2+
3+
module.exports = {
4+
buildDocs
5+
};
File renamed without changes.

config/build/config.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const input = {};
2+
const components = [];
3+
const plugins = [];
4+
const output = {
5+
dist: './dist'
6+
};
7+
8+
module.exports = {
9+
input,
10+
components,
11+
plugins,
12+
output
13+
};

config/build/esm.js

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
const pkg = require('../../package.json');
2+
const alias = require('@rollup/plugin-alias');
3+
const commonjs = require('@rollup/plugin-commonjs');
4+
const { nodeResolve } = require('@rollup/plugin-node-resolve');
5+
const replace = require('@rollup/plugin-replace');
6+
const { babel } = require('@rollup/plugin-babel');
7+
const json = require('@rollup/plugin-json');
8+
const vue = require('rollup-plugin-vue');
9+
const config = require('./config');
10+
11+
const banner =
12+
'/*!\n' +
13+
` * BalmUI v${pkg.version}\n` +
14+
` * (c) 2022-${new Date().getFullYear()} N.Elf-mousE\n` +
15+
' * Released under the MIT License.\n' +
16+
' */';
17+
18+
const baseConfig = {
19+
plugins: {
20+
preVue: [
21+
nodeResolve({
22+
browser: true,
23+
extensions: ['.js', '.json', '.vue']
24+
}),
25+
alias({
26+
entries: [
27+
{
28+
find: 'vue',
29+
replacement: 'node_modules/vue/dist/vue.esm-bundler.js'
30+
}
31+
]
32+
})
33+
],
34+
vue: {
35+
target: 'browser'
36+
},
37+
babel: {
38+
exclude: 'node_modules/**',
39+
extensions: ['.js', '.vue'],
40+
babelHelpers: 'runtime',
41+
presets: [['@babel/preset-env', { modules: false }]]
42+
},
43+
replace: {
44+
preventAssignment: true,
45+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
46+
__VUE_OPTIONS_API__: JSON.stringify(true),
47+
__VUE_PROD_DEVTOOLS__: JSON.stringify(false)
48+
}
49+
}
50+
};
51+
52+
const plugins = [
53+
replace(baseConfig.plugins.replace),
54+
...baseConfig.plugins.preVue,
55+
vue(baseConfig.plugins.vue),
56+
babel(baseConfig.plugins.babel),
57+
commonjs(),
58+
json()
59+
];
60+
61+
const external = ['vue'];
62+
63+
function buildESModule(mix) {
64+
mix.rollup(
65+
{
66+
external,
67+
input: `./src/scripts/index.js`,
68+
plugins
69+
},
70+
{
71+
file: `${config.output.dist}/balm-ui-pro.esm.js`,
72+
format: 'es',
73+
banner
74+
}
75+
);
76+
}
77+
78+
module.exports = buildESModule;

config/build/individual.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const config = require('./config');
2+
3+
function buildIndividual(mix) {
4+
mix.copy(['./dist/css/*.css', './dist/js/*.js'], config.output.dist);
5+
mix.remove(['./dist/css', './dist/js']);
6+
}
7+
8+
module.exports = buildIndividual;

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "balm-ui-pro",
3-
"version": "0.0.0",
3+
"version": "0.1.0",
44
"description": "Javascript error tracking",
55
"keywords": [],
66
"license": "MIT",
@@ -51,6 +51,7 @@
5151
"markdown-loader": "^8.0.0",
5252
"prettier": "^2.6.0",
5353
"prismjs": "^1.28.0",
54+
"rollup-plugin-vue": "^6.0.0",
5455
"vue": "^3.2.30",
5556
"vue-loader": "^17.0.0",
5657
"vue-router": "^4.0.0",

src/scripts/components/form-view/form-item.vue

+3-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
<ui-readonly-item
2828
v-if="config.readonly"
2929
:subitem-class="subitemClass"
30-
:config="config"
3130
:value="value"
3231
>
3332
<slot :name="customSlots.readonly" :value="value"></slot>
@@ -67,7 +66,6 @@ export default {
6766
<script setup>
6867
import { reactive, toRefs, computed, watch, onBeforeMount } from 'vue';
6968
import UiReadonlyItem from './readonly-item.vue';
70-
import { useFormItem } from '../../mixins/form-item';
7169
import getType from '../../utils/typeof';
7270
7371
const props = defineProps({
@@ -104,8 +102,9 @@ const state = reactive({
104102
});
105103
const { formData } = toRefs(state);
106104
107-
const { component, key, componentKey } = useFormItem(props.config);
108-
105+
const component = computed(() => props.config.component || 'unknown-component');
106+
const key = computed(() => props.config.key || 'unknown-key');
107+
const componentKey = computed(() => `${component.value}--${key.value}`);
109108
const customSlots = computed(() => ({
110109
beforeLabel: `before-label__${componentKey.value}`,
111110
afterLabel: `after-label__${componentKey.value}`,
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<template>
2-
<div
3-
:class="[subitemClass, 'mdc-readonly-item', `mdc-readonly-item__${key}`]"
4-
>
2+
<div :class="[subitemClass, 'mdc-readonly-item']">
53
<slot>{{ value }}</slot>
64
</div>
75
</template>
@@ -13,22 +11,14 @@ export default {
1311
</script>
1412

1513
<script setup>
16-
import { useFormItem } from '../../mixins/form-item';
17-
1814
const props = defineProps({
1915
subitemClass: {
2016
type: String,
2117
default: ''
2218
},
23-
config: {
24-
type: Object,
25-
default: () => ({})
26-
},
2719
value: {
2820
type: null,
2921
default: ''
3022
}
3123
});
32-
33-
const { key } = useFormItem(props.config);
3424
</script>

src/scripts/mixins/form-item.js

-15
This file was deleted.

yarn.lock

+21
Original file line numberDiff line numberDiff line change
@@ -3070,6 +3070,11 @@ estraverse@^5.1.0, estraverse@^5.2.0:
30703070
resolved "https://registry.npmmirror.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123"
30713071
integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==
30723072

3073+
estree-walker@^0.6.1:
3074+
version "0.6.1"
3075+
resolved "https://registry.npmmirror.com/estree-walker/-/estree-walker-0.6.1.tgz#53049143f40c6eb918b23671d1fe3219f3a1b362"
3076+
integrity sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==
3077+
30733078
estree-walker@^1.0.1:
30743079
version "1.0.1"
30753080
resolved "https://registry.npmmirror.com/estree-walker/-/estree-walker-1.0.1.tgz#31bc5d612c96b704106b477e6dd5d8aa138cb700"
@@ -4979,6 +4984,22 @@ rimraf@^3.0.2:
49794984
dependencies:
49804985
glob "^7.1.3"
49814986

4987+
rollup-plugin-vue@^6.0.0:
4988+
version "6.0.0"
4989+
resolved "https://registry.npmmirror.com/rollup-plugin-vue/-/rollup-plugin-vue-6.0.0.tgz#e379e93e5ae9a8648522f698be2e452e8672aaf2"
4990+
integrity sha512-oVvUd84d5u73M2HYM3XsMDLtZRIA/tw2U0dmHlXU2UWP5JARYHzh/U9vcxaN/x/9MrepY7VH3pHFeOhrWpxs/Q==
4991+
dependencies:
4992+
debug "^4.1.1"
4993+
hash-sum "^2.0.0"
4994+
rollup-pluginutils "^2.8.2"
4995+
4996+
rollup-pluginutils@^2.8.2:
4997+
version "2.8.2"
4998+
resolved "https://registry.npmmirror.com/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz#72f2af0748b592364dbd3389e600e5a9444a351e"
4999+
integrity sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==
5000+
dependencies:
5001+
estree-walker "^0.6.1"
5002+
49825003
safe-buffer@^5.1.0:
49835004
version "5.2.1"
49845005
resolved "https://registry.npmmirror.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6"

0 commit comments

Comments
 (0)