Skip to content

Commit

Permalink
Fix example, clean up build
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-r-bigelow committed Apr 17, 2018
1 parent 190dc7f commit 4c790cb
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 242 deletions.
178 changes: 0 additions & 178 deletions dist/uki.umd.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/uki.umd.min.js

This file was deleted.

4 changes: 0 additions & 4 deletions examples/basic/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,5 @@
</head>
<body>
<div id="myView"></div>
<script type="application/javascript">

myView.render(d3.select('#myView'));
</script>
</body>
</html>
5 changes: 4 additions & 1 deletion examples/basic/script.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* globals d3 */
import { View } from './uki.esm.js';

class CustomView extends View {
Expand All @@ -8,4 +9,6 @@ class CustomView extends View {
this.d3el.text('Hello, world!');
}
}
export default new CustomView();

const myView = new CustomView(d3.select('#myView'));
myView.render();
10 changes: 2 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uki",
"version": "0.2.0",
"version": "0.2.1",
"description": "Minimal, d3-based Model-View library",
"module": "dist/uki.esm.js",
"jsnext:main": "dist/uki.esm.js",
Expand All @@ -25,13 +25,7 @@
"babel-preset-env": "^1.6.1",
"rollup": "^0.58.0",
"rollup-plugin-babel": "^3.0.3",
"rollup-plugin-commonjs": "^9.1.0",
"rollup-plugin-node-builtins": "^2.1.2",
"rollup-plugin-node-globals": "^1.1.0",
"rollup-plugin-node-resolve": "^3.0.2",
"rollup-plugin-uglify": "^3.0.0",
"serve": "^6.5.5",
"uglify-es": "^3.3.9"
"serve": "^6.5.5"
},
"dependencies": {},
"peerDependencies": {
Expand Down
52 changes: 2 additions & 50 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import builtins from 'rollup-plugin-node-builtins';
import globals from 'rollup-plugin-node-globals';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import babel from 'rollup-plugin-babel';
import uglify from 'rollup-plugin-uglify';
import uglifyEs from 'uglify-es';
import pkg from './package.json';

// Derive some of the configuration from package.json
Expand All @@ -17,28 +11,8 @@ const commonPlugins = [
];

// Basic build formats, without minification
let builds = [
// browser-friendly UMD build
{
input: 'src/module.js',
output: {
name: 'uki',
file: pkg.browser,
format: 'umd',
globals: { 'd3': 'd3' }
},
plugins: [
resolve({
browser: true,
preferBuiltins: true
}), // so Rollup can find dependencies
commonjs(), // so Rollup can convert dependencies to ES modules
builtins(),
globals()
].concat(commonPlugins),
external: peerDependencies
},
// ES Module build for bundlers
export default [
// ES Module
{
input: 'src/module.js',
output: {
Expand All @@ -49,25 +23,3 @@ let builds = [
plugins: commonPlugins
}
];

// Create both minified and un-minified versions for
// builds with 'min.js' in their filenames
let minifiedBuilds = [];
builds.forEach(build => {
if (build.output.file.endsWith('min.js')) {
// Deep copy the build spec, add uglification
let minBuild = Object.assign({}, build);
minBuild.output = Object.assign({}, build.output);
minBuild.plugins = minBuild.plugins.concat([
uglify({}, uglifyEs.minfier)
]);
minifiedBuilds.push(minBuild);

// Keep the un-minified version for development,
// include a sourcemap
build.output.file = build.output.file.replace(/min\.js/, 'js');
build.output.sourcemap = 'inline';
}
});

export default builds.concat(minifiedBuilds);

0 comments on commit 4c790cb

Please # to comment.