Reputation: 3350
My Vue CLI project relies on JSON data from the backend. Because of CORS issues I copied that file into the project's public
folder which works during development. But for the deployment builds I'd like to get rid of that file.
How can I exclude that file from the build process? I suppose the chainWebpack
method in vue.config.js is the key but I can't find how to tweak the different outputs for serve
and build
.
Upvotes: 4
Views: 2052
Reputation: 162
I got this to work:
module.exports = {
chainWebpack: config => {
if (process.env.NODE_ENV === "production") {
config.plugin("copy").tap(opts => {
opts[0][0].ignore.push({ glob: "someFile.json" });
return opts;
});
}
}
};
The process.env.NODE_ENV === "production"
makes the exclusion only apply to the build
output.
Upvotes: 1