Coder Social home page Coder Social logo

generate-json-webpack-plugin's Introduction

generate-json-webpack-plugin

npm version

webpack plugin to generate a custom JSON asset

Installation

npm install generate-json-webpack-plugin

Usage

// webpack.config.js
const GenerateJsonPlugin = require('generate-json-webpack-plugin');

module.exports = {
  // ...
  plugins: [
    // ...
    new GenerateJsonPlugin('my-file.json', {
      foo: 'bar',
    }),
  ],
  // ...
};

This will create a file my-file.json in webpack's output directory, with contents:

{ "foo": "bar" }

You may optionally pass 'replacer' and 'space' arguments as the 3rd and 4th arguments, which will be passed to JSON.stringify to customize the JSON output:

new GenerateJsonPlugin(
  'my-file.json',
  { foo: 'bar', one: 'two' },
  (key, value) => {
    if (value === 'bar') {
      return 'baz';
    }
    return value;
  },
  2
);

my-file.json will contain:

{
  "foo": "baz",
  "one": "two"
}

generate-json-webpack-plugin's People

Contributors

dependabot[bot] avatar elliottsj avatar greenkeeper[bot] avatar greenkeeperio-bot avatar ngyikp avatar renovate-bot avatar renovate[bot] avatar ryanclark avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

generate-json-webpack-plugin's Issues

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

An in-range update of webpack is breaking the build 🚨

Version 4.17.3 of webpack was just published.

Branch Build failing 🚨
Dependency webpack
Current Version 4.17.2
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

webpack is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes v4.17.3

Bugfixes

  • Fix exit code when multiple CLIs are installed
  • No longer recommend installing webpack-command, but still support it when installed
Commits

The new version differs by 7 commits.

  • ee27d36 4.17.3
  • 4430524 Merge pull request #7966 from webpack/refactor-remove-webpack-command-from-clis
  • b717aad Show only webpack-cli in the list
  • c5eab67 Merge pull request #8001 from webpack/bugfix/exit-code
  • 943aa6b Fix exit code when multiple CLIs are installed
  • 691cc94 Spelling
  • 898462d refactor: remove webpack-command from CLIs

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/test.yml
  • actions/checkout v2
  • actions/setup-node v2
npm
package.json
  • del 6.1.1
  • jest 26.6.3
  • prettier 2.8.8
  • webpack 5.91.0

  • Check this box to trigger a request for Renovate to run again on this repository

Generate .json file from source-module by path to it

Something like:

// source.js
module.exports = {
  foo: 'bar'
}

// webpack.config.js
const GenerateJsonPlugin = require('generate-json-webpack-plugin');

module.exports = {
  // ...
  plugins: [
    // ...
    new GenerateJsonPlugin('my-file.json', __dirname + '/source.js')
  ]
  // ...
};

0.3.0 release fails installations on version6 of Node.js (includes LTS)

We have the Node.js LTS release 6.9.0 in place and the release of [email protected] introduced the package.json#engine-field for "node": ">=6.11.5". This breaks installtions with the following message:

error [email protected]: The engine "node" is incompatible with this module. Expected version ">=6.11.5".
error An unexpected error occurred: "Found incompatible module".

This change was introduced by 50e77c5.

Since this was a minor update it breaks SemVer from our point of view. Correct?

Can you use require/loaders in this?

I want to create a manifest file, so want to have the links to the various icon image asset it needs.

Does this have any sort of require support? I'm pretty sure plugin's don't have this kind of access, but I thought I'd check.

Support for watch mode

The plugin is working fine. The only problem I see is when I use with clean-webpack-plugin using watch mode of webpack. The first reload of webpack, it goes fine, the webpack cleans the dist folder and the plugin generates the json perfectly. The second time it reloads, the clean-webpack-plugin cleans the folder and the json is deleted. There is a way to keep regenerating json file every time webpack recompiles? Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.