0

for example, I have a project, and it export a module named 'myNgmodule'; other projects can install and import it to use. but as the usual, we can see all the src code in node_modules. so can I build a 'release' version that does not contain the src code for other use it?

and I found a repo, the library project seems build a release folder, and be imported into main.app, but I don't know how it works

enter image description here

dyh333
  • 385
  • 1
  • 5
  • 15

1 Answers1

0

In order to build Angular in production mode, you have to call

ng build --prod --no-sourcemap

You should also take a look at this documentation about running Angular in production: https://docs.angularjs.org/guide/production

See also this other question: How to bundle an Angular app for production

Haroldo_OK
  • 6,612
  • 3
  • 43
  • 80
  • but if i npm publish my repo, and others install it, it still contains source code ? – dyh333 Nov 17 '17 at 00:56
  • AFAIK, yes; one ugly/hacky way to get around that would be to have a separate repository just for publishing the compiled code. Please keep in mind that the compiled code will still be JS; you can use uglify.js or some code obfusctor to make it less readable and more compact, but it will still be JS. – Haroldo_OK Nov 17 '17 at 10:17
  • yeah, the compiled code will still be JS is ok, as long as it can be imported into another module. so would you please tell me how to publish the compiled code? thanks – dyh333 Nov 20 '17 at 06:51
  • You would need to create a separate repository; that repository would contain only the compiled code. You would publish your package from that repository, instead from your main one. – Haroldo_OK Nov 20 '17 at 10:40