I have a javascript file that isn't part of my project but that needs to be bundled up with it when it is served. This file has contents basically in the form...
FT.manifest({
"foo": "bar",
"id": 3
})
...where the Object part is well formed JSON.
I have webpack set up and am using the copy-webpack-plugin
to move this file to my ./dist
folder along with all my bundled JS and other assets.
Nothing fancy, just a straight file to file copy...
new CopyWebpackPlugin({
patterns: [
{from:`./src/templates/${dirName}/manifest.js`, to: `${dirName}/manifest.js`},
]
})
This works fine when I run webpack in development mode and the copied file looks exactly the same as the original but when I run in production mode the content get inlined and loses the speech marks from around the keys in the Object portion. The output now looks like this...
FT.manifest({foo:"bar",id:3})
Notice the lack of speech marks on foo
and id
. There is obviously some optimisation happening when --mode=production
that is removing the line breaks and other formatting (which is fine) but it is also stripping the speech marks out and this causes problems for some steps that happen down the line.
So, can you tell my why this might be happening what I can do stop this particular file from being optimised during the copying process.
I can't do anything about the format of the particular file as it is from a third party but I can use other plugins or change the process at my end if needed.
Thanks for your help