Alright I spent more than 4 hours on this so time to ask.
What Im trying to do at a very high level is have 2 identical apps that will only get some configuration changed during build time (such as the app name server to connect, etc).
Let’s assume for simplicity this configuration for now will just be a plain object. {app_name: foo_1}
After doing a lot of search I found multi-app config and hooks to do something specific.
So I made a script foo.js and just simple fs.copyFileSync.
Here’s my ionic.config.js
{
"defaultProject": "foo1",
"projects": {
"foo1": {
...
"hooks": {
"build:before": "scripts/app-config.foo1.js",
"serve:before": "scripts/app-config.foo1.js"
}
},
"foo2": {
...
"hooks": {
"build:before": "scripts/foo2.js",
"serve:before": "scripts/foo2.js"
}
},
}
}
And my script foo1.js
const fs = require('fs');
function run(ctx) {
fs.copyFileSync('./src/model/config/foo1.ts', './src/model/config/foo.ts');
process.env.FOO_BAR = 'bar';
window.ENV = 'bar';
console.warn('-------');
console.error(ctx);
}
window.ENV = 'bar';
run();
console.warn('WWWWWWWWWWW');
module.exports = run;
The problem is the hook doesn’t run when I hit ionic serve… And none of the actions are visible anywhere.
1 post - 1 participant