0.1.4 • Published 4 years ago

@sapper-dragon/json v0.1.4

Weekly downloads
5
License
MIT
Repository
github
Last release
4 years ago

@sapper-dragon/json

Decorate your Sapper project with generated dummy JSON.

Installation

npm install @sapper-dragon/json --save-dev
# or
yarn add @sapper-dragon/json --dev

Usage

This project requires the @sapper-dragon/trimmings lib, so look there first for instructions, then come back. 💫

JSON Ipsum

After installing, @sapper-dragon/json will watch for changes to *.js files in src/trimmings/json, and generate a resulting *.json file in static/json based on the rules setup in your js file.

Rules are simple. In your src/trimmings/json/*.js file, export a compile function like so:

export const compile = () => {
	const result = // create your json here...
	console.log(JSON.stringify(result))
}

Note the critical

console.log(JSON.stringify(result))

at the end of the compile function. @sapper-dragon/json needs this to read the output of compile and save it to a *.json file. In other words, the rest of the contents of the compile function can be anything you like, as long as the logged result is valid stringified JSON data.

Config

You can place a trimmings.config.js file in the root of your project to set configutations. These are the defaults:

export default {
	json: {
		input: 'src/trimmings/json', // path to watch *.js files
		filter: /\.js$/, // pattern for files to watch
		outputStatic: 'static/json', // output path
	},
	// ... additional settings from other @sapper-dragon packages...
}
0.1.4

4 years ago

0.1.0

4 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago