├── .gitignore ├── README.md ├── test.js ├── package.json ├── index.js └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## json-minify-brunch 2 | Adds JSON minification support to [Brunch](https://brunch.io). 3 | 4 | ## Usage 5 | Install the plugin via npm with `npm install --save-dev json-minify-brunch`. 6 | 7 | ## License 8 | 9 | The MIT License (MIT) 10 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const {expect} = require('chai'); 4 | const Plugin = require('.'); 5 | 6 | describe('Plugin', () => { 7 | let plugin; 8 | 9 | beforeEach(() => { 10 | plugin = new Plugin({ 11 | plugins: {} 12 | }); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "json-minify-brunch", 3 | "version": "1.0.0", 4 | "description": "Adds JSON minification support to brunch.", 5 | "author": "ns130291", 6 | "homepage": "https://github.com/ns130291/json-minify-brunch", 7 | "license": "MIT", 8 | "repository": { 9 | "type": "git", 10 | "url": "git@github.com:ns130291/json-minify-brunch.git" 11 | }, 12 | "scripts": { 13 | "test": "eslint index.js && mocha" 14 | }, 15 | "dependencies": { 16 | "brunch": "" 17 | }, 18 | "devDependencies": { 19 | "chai": "^4.2", 20 | "eslint": "^6.7", 21 | "mocha": "^6.2", 22 | "eslint-config-brunch": "^1.2" 23 | }, 24 | "eslintConfig": { 25 | "extends": "brunch" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // Documentation for Brunch plugins: 4 | // http://brunch.io/docs/plugins 5 | 6 | class JSONminifyPlugin { 7 | constructor(config) { 8 | this.config = config.plugins.JSONminify || {}; 9 | } 10 | 11 | compileStatic({data, path}) { 12 | //console.log(path); 13 | //const res = JSON.stringify(JSON.parse(data)); 14 | //return res; 15 | return Promise.resolve({data: JSON.stringify(JSON.parse(data))}); 16 | } 17 | 18 | } 19 | 20 | JSONminifyPlugin.prototype.brunchPlugin = true; 21 | JSONminifyPlugin.prototype.type = 'template'; 22 | 23 | JSONminifyPlugin.prototype.extension = 'json'; 24 | JSONminifyPlugin.prototype.staticTargetExtension = 'json'; 25 | 26 | JSONminifyPlugin.prototype.defaultEnv = 'production'; 27 | 28 | module.exports = JSONminifyPlugin; 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2020 ns130291 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | --------------------------------------------------------------------------------