jsonc-loader
v0.1.1
Published
<div align="center"> <a href="https://github.com/webpack/webpack"> <img width="200" height="200" src="https://webpack.js.org/assets/icon-square-big.svg"> </a> </div>
Downloads
1,528
Readme
jsonc-loader
The jsonc-loader
resolves import/require()
on a JSONC(or jsonc) file into legit JSON object.
Getting Started
To begin, you'll need to install jsonc-loader
:
$ npm install jsonc-loader --save-dev
Then add the loader to your webpack
config. For example:
harrypotter.jsonc
/**
* @description This is a json file describing harrypotter book series, with some comment enabled
* @author John Doe
*/
{
"1st": { "name": "Harry Potter and the Sorcerer's Stone" }, // inline comment is also fine
"2nd": { "name": "Harry Potter and the Chamber of Secrets" },
"3rd": { "name": "Harry Potter and the Prisoner of Azkaban" },
"4th": { "name": "Harry Potter and the Goblet of Fire" },
"5th": { "name": "Harry Potter and the Order of the Phoenix" },
"6th": { "name": "Harry Potter and the Half-Blood Prince" },
"7th": { "name": "Harry Potter and the Deathly Hallows" }
}
webpack.config.js
module.exports = {
module: {
rules: [
{
test: /.jsonc$/,
use: [
{
loader: `jsonc-loader`,
},
],
},
],
},
};
And run webpack
via your preferred method.
Contributing
Please take a moment to read our contributing guidelines if you haven't yet done so.