-
Notifications
You must be signed in to change notification settings - Fork 12k
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
Services do not work in production build #808
Comments
Heya @unnijeevan, I tried this on My commands were these:
|
Hi filip Thank you very much for the reply,it works now but it seems prod build doesn't bundle things anymore...Previously it used to be just 4 or 5 miles bundled.Not sure how is it different from dev build now |
The app itself is bundled, even though all vendor files are being copied over to Check your |
Hi @filipesilva I also encountered this issue today. If I create the service in the "app/shared" folder and then add it to main.ts, I will have the same 404 error for missing shared/index.js. However, if the service is placed in the "app" folder as you did, it will build and load correctly via ng build --prod.
main.js import { bootstrap } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { TestprojAppComponent, environment } from './app/';
import { MyTestServiceService } from './app/shared';
if (environment.production) {
enableProdMode();
}
bootstrap(TestprojAppComponent, [
MyTestServiceService
]); Error:
My system:
|
Hi @lifan0127, beta.6 should have a broader fix for that issue via #1028, but meanwhile there is a solution in #953. |
Thanks @filipesilva I did come up with the same solution of importing this service from 'app/index.ts' which fixed the problem. Look forward to beta 6! |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
3.Created a sample app using angular cli and created a service under shared folder.
Run ng build -prod
Run ng serve -prod
Get error
test.zip
The text was updated successfully, but these errors were encountered: