Skip to content

generate dev environment, add <vue-vega> component, and add example #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
current node
last 2 versions and > 2%
ie > 10
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.DS_Store
node_modules/
/dist/

# local env files
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw*
17 changes: 17 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const devPresets = ['@vue/babel-preset-app'];
const buildPresets = [
[
'@babel/preset-env',
// Config for @babel/preset-env
{
// Example: Always transpile optional chaining/nullish coalescing
// include: [
// /(optional-chaining|nullish-coalescing)/
// ],
},
],
'@babel/preset-typescript',
];
module.exports = {
presets: (process.env.NODE_ENV === 'development' ? devPresets : buildPresets),
};
68 changes: 68 additions & 0 deletions build/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// rollup.config.js
import path from 'path';
import vue from 'rollup-plugin-vue';
import alias from '@rollup/plugin-alias';
import json from "@rollup/plugin-json";
import ts from "rollup-plugin-ts";

const projectRoot = path.resolve(__dirname, '..');

const commonSettings = {
external: ['vue', 'vue-demi', 'vega-embed'],
}

const commonPlugins = [
alias({
entries: [
{
find: '@',
replacement: `${path.resolve(projectRoot, 'src')}`,
},
],
}),
ts({
}),
json()
];

export default [
// ESM build to be used with webpack/rollup.
{
...commonSettings,
input: 'src/entry.ts',
output: {
format: 'esm',
file: 'dist/library.esm.js'
},
plugins: [
...commonPlugins,
vue()
]
},
// SSR build.
{
...commonSettings,
input: 'src/entry.ts',
output: {
format: 'cjs',
file: 'dist/library.ssr.js'
},
plugins: [
...commonPlugins,
vue({ template: { optimizeSSR: true } })
]
}/*,
// Browser build.
{
...commonSettings,
input: 'src/entry.iife.ts',
output: {
format: 'iife',
file: 'dist/library.js'
},
plugins: [
...commonPlugins,
vue()
]
}*/
];
7 changes: 7 additions & 0 deletions dev/serve.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Vue from 'vue';
import Dev from './serve.vue';

new Vue({
render: (h) => h(Dev),
}).$mount("#app");

43 changes: 43 additions & 0 deletions dev/serve.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<script lang="ts">
import { defineComponent } from 'vue-demi';

// Uncomment import and local "components" registration if library is not registered globally.
import { VueVega } from '@/entry';

export default defineComponent({
name: 'ServeDev',
components: {
VueVega,
},
data() {
return {
spec: {
$schema: "https://vega.github.io/schema/vega-lite/v5.json",
description: "A simple bar chart with embedded data.",
mark: "bar",
encoding: {
x: { field: "a", type: "nominal", axis: { labelAngle: 0 } },
y: { field: "b", type: "quantitative" },
},
data: { "values" : [
{ a: "A", b: 28 },
{ a: "B", b: 55 },
{ a: "C", b: 43 },
{ a: "D", b: 91 },
{ a: "E", b: 81 },
{ a: "F", b: 53 },
{ a: "G", b: 19 },
{ a: "H", b: 87 },
{ a: "I", b: 52 },
] },
}
}
}
});
</script>

<template>
<div id="app">
<vue-vega :spec="spec" />
</div>
</template>
Loading