1.0.6 • Published 7 years ago

data-json-optimizer v1.0.6

Weekly downloads
7
License
MIT
Repository
github
Last release
7 years ago

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.

1.0.6

7 years ago

1.0.5

7 years ago

1.0.3

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago