Skip to content

Vizhub D3js workflow

Posted on:September 23, 2022 at 03:22 PM

Workflow

index.js ------> bundle.js
delhiIndex.js -------> delhiBundle.js

rollup.config.js file:

import { terser } from "rollup-plugin-terser";

export default [
  {
    input: "index.js",
    external: ["d3"],
    output: {
      file: "bundle.js",
      format: "iife",
      sourcemap: true, // creates a sourcemap(bundle.js.map) file for debugging
      globals: { d3: "d3" },
    },
    plugins: [terser()],
  },
  {
    input: "delhiIndex.js",
    external: ["d3"],
    output: {
      file: "delhiBundle.js",
      format: "iife",
      sourcemap: true, // creates a sourcemap(delhiBundle.js.map) file for debugging
      globals: { d3: "d3" },
    },
    plugins: [terser()],
  },
];

package.json file:

{
  "scripts": {
    "build": "rollup -c"
  },
  "devDependencies": {
    "rollup": "latest",
    "rollup-plugin-terser": "^5.1.0"
  }
}

To create a package.json file

$ npm init

To update npm

$ npm install npm@latest -g