简体   繁体   中英

Ember-cli build for production is missing dependencies

I've been seeing something weird when doing ember build --environment=production and that is that certain dependencies are missing when I run the built app on my server that are not missing if I just do a development build.

The first error shows in the console when I just go to the home page of my app, and says "Ember.Handlebars.compile is not a function" and further on in my app, I get an error that my pikaday component (for a date picker) is missing, but again, it's not missing if I just do ember build .

I'm not very good at debugging minimized javascript, so I'm not sure how to solve this.

Here is my entire config/environment.js file (ignore the endpoint stuff, it's just for our intranet):

/* jshint node: true */

module.exports = function(environment) {
  var ENV = {
    modulePrefix: 'star',
    environment: environment,
    baseURL: '/',
    locationType: 'hash',
    EmberENV: {
      FEATURES: {
        // Here you can enable experimental features on an ember canary build
        // e.g. 'with-controller': true
      }
    },

    APP: {
      // Here you can pass flags/options to your application instance
      // when it is created
    }
  };

  if (environment === 'development') {
    ENV.API_ENDPOINT = 'http://10.94.171.94';
    ENV.AUTH_ENDPOINT = 'http://10.94.171.94';
    // ENV.APP.LOG_RESOLVER = true;
    ENV.APP.LOG_ACTIVE_GENERATION = true;
    // ENV.APP.LOG_TRANSITIONS = true;
    // ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
    ENV.APP.LOG_VIEW_LOOKUPS = true;
  }

  if (environment === 'test') {
    // Testem prefers this...
    ENV.baseURL = '/';
    ENV.locationType = 'auto';

    // keep test console output quieter
    ENV.APP.LOG_ACTIVE_GENERATION = false;
    ENV.APP.LOG_VIEW_LOOKUPS = false;

    ENV.APP.rootElement = '#ember-testing';
  }

  if (environment === 'production') {
    ENV.API_ENDPOINT = 'http://10.94.171.94';
    ENV.AUTH_ENDPOINT = 'http://10.94.171.94';
    ENV.baseURL = '/';
    locationType = 'hash';
  }

  ENV['simple-auth'] = {
    //https://github.com/simplabs/ember-simple-auth/tree/master/packages/ember-simple-auth-cookie-store
    store: 'simple-auth-session-store:cookie',
    authorizer: 'authorizer:custom',
    routeAfterAuthentication: 'projects',
    authenticationRoute: 'index',
    crossOriginWhitelist: [
      ENV.API_ENDPOINT,
      ENV.AUTH_ENDPOINT

    ]
  }

  return ENV;
};

Brocfile.js

  /* global require, module */

var pickFiles = require('broccoli-static-compiler');
var mergeTrees = require('broccoli-merge-trees');
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
var fontAwesome;
var app = new EmberApp({
  vendorFiles: {
    'es5-shim.js': 'bower_components/es5-shim/es5-shim.js',
    'es5-sham.js': 'bower_components/es5-shim/es5-sham.js'
  }
});

//these font files will be put into the assets/fonts folder in public/ and dist/
fontAwesome = pickFiles('vendor/sb-admin-2/font-awesome-4.2.0/fonts', {
  srcDir: '/',
  files: ['*'],
  destDir: '/assets/fonts'
});

// Use `app.import` to add additional libraries to the generated
// output files.

//only using the js and font files from bootstrap, sass stylesheets are in app/styles
app.import(app.bowerDirectory + '/moment/moment.js');
app.import(app.bowerDirectory + '/respond/dest/respond.min.js');
app.import(app.bowerDirectory + '/bootstrap-sass-official/assets/javascripts/bootstrap/tooltip.js');
app.import('vendor/sb-admin-2/js/bootstrap.min.js');
app.import(app.bowerDirectory + '/ember-addons.bs_for_ember/dist/js/bs-core.min.js');
app.import(app.bowerDirectory + '/ember-addons.bs_for_ember/dist/js/bs-progressbar.min.js');
app.import(app.bowerDirectory + '/ember-addons.bs_for_ember/dist/js/bs-nav.min.js');
app.import(app.bowerDirectory + '/ember-addons.bs_for_ember/dist/js/bs-badge.min.js');
app.import('vendor/sb-admin-2/js/plugins/metisMenu/metisMenu.js');
app.import('vendor/sb-admin-2/css/plugins/metisMenu/metisMenu.css');
app.import('vendor/sb-admin-2/js/sb-admin-2.js');
//sb-admin-2 scss is imported in app/styles/app.scss
app.import('vendor/sb-admin-2/font-awesome-4.2.0/css/font-awesome.min.css');

//placholder attribute polyfill
app.import(app.bowerDirectory + '/better-dom/dist/better-dom-legacy.js');
app.import(app.bowerDirectory + '/better-dom/dist/better-dom.js');
app.import(app.bowerDirectory + '/better-placeholder-polyfill/dist/better-placeholder-polyfill.js');

// If you need to use different assets in different
// environments, specify an object as the first parameter. That
// object's keys should be the environment name and the values
// should be the asset to use in that environment.
//
// If the library that you are including contains AMD or ES6
// modules that you would like to import into your application
// please specify an object with the list of modules as keys
// along with the exports of each module as its value.

module.exports = mergeTrees([
  app.toTree(),
  fontAwesome]);

bower.json

{
  "name": "star",
  "dependencies": {
    "handlebars": "~1.3.0",
    "jquery": "1.11.1",
    "ember": "1.6.1",
    "ember-data": "1.0.0-beta.10",
    "ember-resolver": "0.1.8",
    "loader.js": "stefanpenner/loader.js#1.0.1",
    "ember-cli-shims": "stefanpenner/ember-cli-shims#0.0.3",
    "ember-cli-test-loader": "rwjblue/ember-cli-test-loader#0.0.4",
    "ember-load-initializers": "stefanpenner/ember-load-initializers#0.0.2",
    "ember-qunit": "0.1.8",
    "ember-qunit-notifications": "0.0.4",
    "qunit": "~1.15.0",
    "moment": "~2.8.1",
    "components-font-awesome": "~4.2.0",
    "pikaday": "~1.2.0",
    "ember-simple-auth": "0.6.7",
    "better-placeholder-polyfill": "~1.2.0",
    "es5-shim": "~4.0.1",
    "html5shiv": "~3.7.2",
    "respond": "~1.4.2",
    "bootstrap-sass-official": "~3.3.0",
    "ember-addons.bs_for_ember": "~0.7.0"
  },
  "resolutions": {
    "jquery": ">= 1.7.0 < 2.2.0",
    "ember": "1.6.1"
  }
}

package.json

{
  "name": "star",
  "version": "0.0.0",
  "private": true,
  "directories": {
    "doc": "doc",
    "test": "tests"
  },
  "scripts": {
    "start": "ember server",
    "build": "ember build",
    "test": "ember test"
  },
  "repository": "https://github.com/stefanpenner/ember-cli",
  "engines": {
    "node": ">= 0.10.0"
  },
  "author": "",
  "license": "MIT",
  "devDependencies": {
    "body-parser": "^1.2.0",
    "broccoli-asset-rev": "0.3.0",
    "broccoli-ember-hbs-template-compiler": "^1.6.1",
    "broccoli-merge-trees": "^0.2.0",
    "broccoli-sass": "^0.2.2",
    "broccoli-static-compiler": "^0.2.0",
    "connect-restreamer": "^1.0.1",
    "ember-cli": "0.1.1",
    "ember-cli-ic-ajax": "0.1.1",
    "ember-cli-inject-live-reload": "^1.2.2",
    "ember-cli-qunit": "0.1.0",
    "ember-cli-simple-auth": "^0.6.7",
    "ember-cli-simple-auth-cookie-store": "^0.6.7",
    "ember-data": "1.0.0-beta.10",
    "ember-pikaday": "^0.1.0",
    "express": "^4.8.5",
    "glob": "^4.0.5",
    "liquid-fire": "^0.12.0"
  }
}

I've seen that error when using ember-forms . If you're using that lib, it currently has a dependency on the Handlebars runtime compiler (which is no bueno).

You can follow that issue to monitor progress.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM