data-json-optimizer

1.0.6 • Public • Published

data-json-optimizer

A small utility to merge all data.json files from the webpack application

DataJsonOptimizer is a small utility to merge all data.json files from the webpack application and create following final data json file.

  • game-data.json => It has all keys in hyphenated.
  • game-data-in-camel-case.json => It has all keys in camelcase to access in js.

Why this?

Application has too many data.json files which is carrying the all game properties and keys are in hyphenated. In implementation, we are using camelcase keys. For this, if we start converting the all keys on the fly on client side then it slows down the whole application. So we are creating the final json files on application compile/build time only.

Installation

npm install -D data-json-optimizer

Usage

    const OpenerForWebpack = require('data-json-optimizer');
    module.exports = {
      entry: "./app.js",
      output: {
      },
      plugins: [
        new DataJsonOptimizer(),
        new webpack.WatchIgnorePlugin([/game-data.*\.json$/])
      ]
    };

Usage with webpack-multi-configurator plugin with angularity

var webpack           = require('webpack');
var angularity        = require('webpack-angularity-solution');
var dataJsonOptimizer = require('data-json-optimizer');
 
const PORT = '3000';
 
module.exports = angularity(process.env, {port: PORT})
  .append(addDataJsonOptimizer)
  .otherwise('app+test')
  .resolve();
 
 
function addDataJsonOptimizer(configurator, options) {
  return configurator
    .merge({
        plugins: [
          new dataJsonOptimizer(),
          new webpack.WatchIgnorePlugin([/game-data.*\.json$/])
        ]
      }
    );
}

Contributing

In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.

Readme

Keywords

Package Sidebar

Install

npm i data-json-optimizer

Weekly Downloads

1

Version

1.0.6

License

MIT

Last publish

Collaborators

  • amitesh-kumar