Skip to content

JS files from 3rd party to be included in index.html are not copied to dist/ **in prod mode** #949

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
feloy opened this issue May 28, 2016 · 5 comments

Comments

@feloy
Copy link

feloy commented May 28, 2016

  1. OS? Ubuntu Linux 14.04.4 LTS
  2. Versions.
    angular-cli: 1.0.0-beta.5
    node: 5.10.1
    os: linux x64

Repro steps.

ng new angular-cli-primeng-issue && cd angular-cli-primeng-issue
npm install primeng --save
npm install primeui --save

angular-cli-build.js

var Angular2App = require('angular-cli/lib/broccoli/angular2-app');

module.exports = function(defaults) {
  return new Angular2App(defaults, {
    vendorNpmFiles: [
      'systemjs/dist/system-polyfills.js',
      'systemjs/dist/system.src.js',
      'zone.js/dist/**/*.+(js|js.map)',
      'es6-shim/es6-shim.js',
      'reflect-metadata/**/*.+(js|js.map)',
      'rxjs/**/*.+(js|js.map)',
      '@angular/**/*.+(js|js.map)',
      'primeng/**/*.+(js|js.map)',
      'primeui/**/*'
    ]
  });
};

src/system-config.ts

const map: any = {
  'primeng': 'vendor/primeng'
};

/** User packages configuration. */
const packages: any = {
  'primeng': { defaultExtension: 'js' }
};
...

src/index.html

...
<script src="vendor/primeui/primeui-ng-all.min.js"></script>
...

The failure

$ ng build && ls dist/vendor/primeui/primeui-ng-all.min.js 
[...build...]
dist/vendor/primeui/primeui-ng-all.min.js
$ ng build -prod && ls dist/vendor/primeui/primeui-ng-all.min.js 
[...build...]
dist/vendor/primeui/primeui-ng-all.min.js NOT FOUND

Mention any other details that might be useful.

The solution I have found is

  • do not include script from src/index.html
  • define the polyfills option to AngularApp in angular-cli-build.js:
var Angular2App = require('angular-cli/lib/broccoli/angular2-app');

module.exports = function(defaults) {
  return new Angular2App(defaults, {
      vendorNpmFiles: [
          'systemjs/dist/system-polyfills.js',
          'systemjs/dist/system.src.js',
          'zone.js/dist/**/*.+(js|js.map)',
          'es6-shim/es6-shim.js',
          'reflect-metadata/**/*.+(js|js.map)',
          'rxjs/**/*.+(js|js.map)',
          '@angular/**/*.+(js|js.map)',
          'primeng/**/*.+(js|js.map)',
          'primeui/**/*'
      ],
      polyfills: [
          'vendor/es6-shim/es6-shim.js',
          'vendor/reflect-metadata/Reflect.js',
          'vendor/systemjs/dist/system.src.js',
          'vendor/zone.js/dist/zone.js',
          'vendor/primeui/primeui-ng-all.min.js'
      ]
  });
};

Questions

  • Is it the preconized solution?
  • If so, this solution is not documented anywhere
  • if so, it could be interesting to get the default polyfills in angular-cli-build.js, instead of having to get them in node_modules/angular-cli/lib/broccoli/angular2-app.js
@feloy feloy changed the title JS files fom 3rd party to be included in index.html are not copied to dist/ **in prod mode** JS files from 3rd party to be included in index.html are not copied to dist/ **in prod mode** May 29, 2016
@filipesilva
Copy link
Contributor

The current recommended solution is to never add script tags to index.html to load libraries, but rather to use SystemJS configuration instead to load all these.

Production builds use bundling of all dependencies and thus will never generate individual vendor files (except for the ones initially needed to load SystemJS).

The polyfills solution is not the recommended one.

@lamaan
Copy link

lamaan commented Jun 14, 2016

Having the same issue.
Could you @filipesilva add some more detail about how to do this for some example "/lib/some.js" file . Instead of including it in the index.html, how do I include it in systemJS configuration?

@filipesilva
Copy link
Contributor

@lamaan you can find an example in this issue #1015

@lamaan
Copy link

lamaan commented Jun 18, 2016

Thanks, that fixed it for me.

-----Original Message-----
From: "Filipe Silva" [email protected]
Sent: ‎17/‎06/‎2016 02:03
To: "angular/angular-cli" [email protected]
Cc: "lamaan" [email protected]; "Mention" [email protected]
Subject: Re: [angular/angular-cli] JS files from 3rd party to be included in index.html are not copied to dist/ in prod mode (#949)

@lamaan you can find an example in this issue #1015


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#949 (comment)

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants