question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue
  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

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
lamaancommented, Jun 18, 2016

Thanks, that fixed it for me.

-----Original Message----- From: “Filipe Silva” notifications@github.com Sent: ‎17/‎06/‎2016 02:03 To: “angular/angular-cli” angular-cli@noreply.github.com Cc: “lamaan” lamaan@lamaan.com; “Mention” mention@noreply.github.com 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 https://github.com/angular/angular-cli/issues/1015


You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/angular/angular-cli/issues/949#issuecomment-226655832

0reactions
angular-automatic-lock-bot[bot]commented, Sep 6, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why doesn't Webpack copy the index.html file to the dist ...
When running "npm run build" to build a project in Webpack, html files are not copied into the dist directory. Based off the...
Read more >
Handling common JavaScript problems - MDN Web Docs
Maybe not so simple, but this article should at least give you a start, and some ideas on how to tackle the JavaScript-related...
Read more >
How to solve vue.js prod build assets relative path problem
I copied the dist folder to one of my wamp apache server's www folder. ... I opened the index.html file it had a...
Read more >
Client libraries and front-end workflow - Experience League
Store CSS/JS in small discrete files for easier development and maintenance; Manage dependencies on third party frameworks in an organized ...
Read more >
Getting started · Bootstrap
No docs or original source files are included. ... JavaScript --> <script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js" ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found