Last active
August 15, 2024 15:13
-
-
Save vasind/22122632be15f3bc98a092ab012524e2 to your computer and use it in GitHub Desktop.
Ember CLI performance improvements and tips
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Credits to the following posts that helps me to reduce build times drastically | |
// https://discuss.emberjs.com/t/tips-for-improving-build-time-of-large-apps/15008/12 | |
// https://www.gokatz.me/blog/how-we-cut-down-our-ember-build-time/ | |
//ember-cli-build.js | |
let EmberApp = require('ember-cli/lib/broccoli/ember-app'); | |
let env = EmberApp.env(), | |
IS_PROD = env === 'production', | |
IS_TEST = env === 'test' ; | |
module.exports = function(defaults) { | |
let app = new EmberApp(defaults, { | |
hinting: IS_TEST, // Disable linting for all builds but test | |
tests: IS_TEST, // Don't even generate test files unless a test build | |
"ember-cli-babel": { | |
includePolyfill: IS_PROD // Only include babel polyfill in prod | |
}, | |
autoprefixer: { | |
sourcemap: false // Was never helpful | |
}, | |
sourcemaps: { | |
enabled: IS_PROD // CMD ALT F in chrome is *almost* as fast as CMD P | |
}, | |
fingerprint: { | |
enabled: IS_PROD //Asset rewrite will takes more time and fingerprinting can be omitted in development | |
}, | |
sassOptions: { | |
// moving from compass compiler to node gave huge improvement | |
implementation: nodeSass, //implementation here is node-sass, | |
sourceMap : false //will debug with generated CSS than sourcemap :) | |
}, | |
// Only import other polyfills in production | |
if (IS_PROD) { | |
app.import('vendor/ie-polyfill.js'); | |
} | |
return app.toTree(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// config/environment.js | |
if (environment === 'development') { | |
ENV['ember-cli-mirage'] = { | |
enabled: false, | |
excludeFilesFromBuild: true // Don't include lodash and everything else mirage needs | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Commenting here because there has been some confusion / concern:
I would not use the IS_TEST or check
environment === test
. The official docs, and many expectations are around the presence of/tests
, which runs in thedevelopment
environment. If there are any build-time transforms or configuration around the test environment, than the default/tests
would not be available.for completeness, and some may already know this -- given the contents of the gist, I'd flat out disable
hinting
and if you're disablingtests
for build performance, (Like if running 3 times withtests: true
and 3 times withtests: false
(with deletingtmp
anddist
between each) shows dramatic (> 10%) time difference) then I'd look in to instead going a multi-app approach (not engines, cause they eagerly build, iirc) -- this way the amount of code in either app is reduced significantly