Giulia Chiola
Giulia Chiola's Blog

Giulia Chiola's Blog

Add comments in JSON file

Giulia Chiola's photo
Giulia Chiola
ยทJan 18, 2021ยท

2 min read

Spoiler: I lied.


giphy video

As you know, you cannot and will never can add comments in JSON file but you can add something that seems a comment ๐Ÿ˜ˆ:

"_____________________________CSS_____________________________": "",

Using this key:value pair separator you can tidy a long and complex JSON as scripts in package.json

  "name": "super-styleguide",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "_____________________________CSS_____________________________": "",
    "stylelint": "stylelint 'src/scss/**/*.scss' || echo \"Stylelint failed for some file(s).\"",
    "scss-to-css-dev": "node-sass --output-style expanded src/scss/styles/develop -o src/css/",
    "css-to-postcss-dev": "postcss src/css --dir dist/css",
    "styles-dev": "npm run stylelint && npm run scss-to-css-dev && npm run css-to-postcss-dev",
    "_____________________________SVG_____________________________": "",
    "clean-svgo": "rimraf src/icons/svgo/*",
    "svg-optimize": "npm run clean-svgo && node scripts/svgo.js",
    "_____________________________Webpack bundle__________________": "",
    "bundle": "webpack --env.production",
    "bundle:uiengine:chunk": " cross-env NODE_ENV=production webpack --env.production --config webpack.uiengine.config.js",

๐Ÿ“š More info

JavaScript Object Notation (JSON) - MDN

Share this