I build my project with wepback, but cant seem to exclude my json file from it.
I am using node.js and trying to store the path of the json file like this, and this codeblock is inside my index.js file.
const users = require('./users.json')
console.log(users)
Inside the webpack.config.js i am trying to exclude that file.
externals: {
"./users.json": "./users.json"
}
However it doesnt really work. I expect my bundle to exclude the json file so i can access it through my index.js file.
Anyone can help me out here?
Excluding a JSON file can achieved with the externals option for sure:
externals: {
"./users.json": "[]"
}
The configuration replaces the import of ./users.json
with an empty array literal in bundled code.