Skip to content

Commit

Permalink
Add bundled example app for Vue Vanilla
Browse files Browse the repository at this point in the history
* Add rollup config to bundle the Vue Vanilla example
* Add to examples app

Part of #1706
  • Loading branch information
lucas-koehler authored and sdirix committed Jan 25, 2023
1 parent ce4ec0f commit 1b22f55
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/examples-app/index.html
Expand Up @@ -13,6 +13,7 @@ <h1>JSON Forms Examples</h1>
<li><a href="react-vanilla">React Vanilla Renderers</a></li>
<li><a href="react-material">React Material Renderers</a></li>
<li><a href="angular-material">Angular Material Renderers</a></li>
<li><a href="vue-vanilla">Vue Vanilla Renderers</a></li>
</ul>
</body>
</html>
3 changes: 2 additions & 1 deletion packages/examples-app/prepare-examples-app.js
Expand Up @@ -13,7 +13,8 @@ const packagesDir = join(__dirname, '..');
const examples = {
'react-vanilla': join(packagesDir, 'vanilla-renderers', 'example', 'dist'),
'react-material': join(packagesDir, 'material-renderers', 'example', 'dist'),
'angular-material': join(packagesDir, 'angular-material', 'example', 'dist')
'angular-material': join(packagesDir, 'angular-material', 'example', 'dist'),
'vue-vanilla': join(packagesDir, 'vue', 'vue-vanilla', 'example', 'dist')
}

// Clean and recreate dist dir
Expand Down
16 changes: 16 additions & 0 deletions packages/vue/vue-vanilla/example/index.bundled.html
@@ -0,0 +1,16 @@
<!doctype html>
<html>

<head>
<meta charset="utf-8">
<title>JSON Forms Vue Vanilla RendererSet</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="bundle.css">
</head>

<body>
<div id="app"></div>
</body>
<script src="bundle.js"></script>

</html>
3 changes: 2 additions & 1 deletion packages/vue/vue-vanilla/package.json
Expand Up @@ -44,7 +44,8 @@
"build:do": "cross-env NODE_ENV=production rollup --config rollup.config.js",
"build": "run-s --continue-on-error build:pre build:do build:after",
"build:after": "symlink-dir ../../core ../vue/node_modules/@jsonforms/core",
"clean": "rimraf lib",
"build:examples-app": "rollup -c rollup.example.config.js",
"clean": "rimraf lib example/dist",
"doc": "typedoc --name 'JSON Forms Vue Vanilla Renderers' --mode file --out docs src --ignoreCompilerErrors",
"test": "vue-cli-service test:unit"
},
Expand Down
52 changes: 52 additions & 0 deletions packages/vue/vue-vanilla/rollup.example.config.js
@@ -0,0 +1,52 @@
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import nodeResolve from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import copy from 'rollup-plugin-copy';
import css from 'rollup-plugin-import-css';
import typescript from 'rollup-plugin-typescript2';
import vue from 'rollup-plugin-vue';

/**
* @type {import('rollup').RollupOptions}
*/
const config = {
input: 'dev/serve.ts',
output: {
file: 'example/dist/bundle.js',
format: 'iife',
sourcemap: true
},
plugins: [
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
preventAssignment: true, // recommended to be set by library to be forward compatible
}),
vue(),
nodeResolve({ browser: true }),
// Transform mixed because some JsonForms modules use import and require
commonjs({ transformMixedEsModules: true }),
css(),
json(),
typescript({
tsconfigOverride: {
include: null,
compilerOptions: {
// Do not emit typescript declarations for our bundled example app
declaration: false
}
}
}),
copy({
targets: [
{
src: 'example/index.bundled.html',
dest: 'example/dist',
rename: () => 'index.html'
},
]
}),
]
}

export default config;

0 comments on commit 1b22f55

Please sign in to comment.