I have a folder with some mock data in "src/api/mock" folder which contains some ts and JSON files. I want Webpack to exclude them when it builds for production. I tried using the below rule but its not working. Any suggestions?
module: {
rules: [
{
test: /.(ts|json)$/i,
exclude: ['/src/api/mock/'],
},
],
},
2
Answers
Try this if it works
since you are using typescript you should use
tsconfig.json
. when you init this file you should have this alreadyJust add the correct path for this ‘/src/api/mock/’ to the array. I think
ts-loader
follows this file’s configuration