How to specify compression for custom build environment in Ember

泄露秘密 提交于 2019-12-02 01:27:49

This is configured in ember-cli-build.js file of your project. By default fingerprinting is only enabled in production (app.env === 'production'). This could be changed by fingerprint.enabled option. The same applies to ember-cli-uglify for JavaScript minification and minifyCSS options. Configure these options as required:

'use strict';

const EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = function(defaults) {
  let env = EmberApp.env();
  let isProductionLike = ['production', 'qa'].includes(env);
  let app = new EmberApp({
    'ember-cli-uglify': {
      enabled: isProductionLike
    },
    fingerprint: {
      enabled: isProductionLike
    },
    minifyCSS: {
      enabled: isProductionLike
    },
    sourcemaps: {
      enabled: !isProductionLike
    }
  });

  return app.toTree();
};

ember-cli-uglify option was named minifyJS in ember-cli-uglify 1.x. The addon was updated in default blueprint of ember-cli 2.16. Change option name accordingly if you are still using ember-cli-uglify@1.x. At the point of time writing this answer, ember-cli docs had not yet reflected that breaking change. It was introduced here. Also note that there is an open issue about it, so it might change in the future again.

More details and options are available in asset compilation chapter of ember-cli docs.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!