I have a build.config.xml that has a couple of strings in it like $FABRIC_API_KEY. I want to replace this with process.env.FABRIC_API_KEY in a new file config.xml (build.config.xml should remain the same). I have tried using CopyWebpackPlugin, but I can't seem to get this to do anything.
var CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
...
resolve: {
extensions: ['.ts', '.js', '.json', '.xml'],
...
plugins: [
ionicWebpackFactory.getIonicEnvironmentPlugin(),
new CopyWebpackPlugin([{
from: 'build.config.xml',
to: 'config.xml',
transform: function (content) {
content = content
.replace('$FABRIC_API_SECRET', process.env.FABRIC_API_SECRET)
.replace('$FABRIC_API_KEY', process.env.FABRIC_API_KEY);
return content;
},
}]),
],
};
The file does other things (builds ionic) and everything else works as expected. There are no errors or anything, and config.xml does not get created.
What can I do to copy a file and replace strings in it? I am open to using another plugin.