-1

What is the best way to minify the JSON files on the angular production build?. I have a JSON file in assets folder which is copying to output folder as it is when the production build is done.

In development file will be like Development file and in production the file should be like Production file

1 Answers1

0

For now I am doing with post build command which runs the following script

import { writeFile, readFile } from 'fs';

readFile('./src/assets/errors.json', (readErr, data) => {
    if (data) {
        var minified = JSON.stringify(JSON.parse(data));

        writeFile('./www/assets/errors.json', minified, 'utf8', (err) => {
            if (err) {
                return console.log(err);
            }
        });
    }
    else {
        return console.log(readErr);
    }
});