Our Ember application is developed in 2.8 version and we follow POD structure.
We are generating two different builds as below
1) For our dev server : No change in code,just do build
2) For our test server: Delete a section in HBS and also remove a route from router.js then do build
And we take build using "npm run-scripts build" which is configured in our package.json as below
"scripts": {
"build": "ember build",
"start": "ember server",
"test" : "ember test"
},
I would like to know in ember 2.8v can i have a condition written to remove the section based on build.
Like if i give npm run-scripts buildDev it will do the regular build
and if i give npm run-scripts buildTest it will do sections removals and give a build
but in package.json both will be configured like
"scripts": {
"build" : "ember build",
"buildDev" : "ember build --environment=production",
"buildTest": "ember build --environment=production",
"start": "ember server",
"test" : "ember test"
},
Do you only want to disable a section or do you need to remove it from the build?
Its pretty easy if you want to only disable something:
First you can use environment variables in your
config/environment.js. So something like this:In your
package.jsonyou could do this:This uses
cross-envto set the env variable in windows and *nix systems.You can then import the config and use it:
However if you want to actually remove some code you could write your own addon for this to replace some variable with
trueorfalse. then the minifier will remove the code.