cankayacan / ngx-library-starter

Angular >2 library stater with rollup.
4 stars 2 forks source link

Problem with external html and scss files #1

Closed Ks89 closed 7 years ago

Ks89 commented 7 years ago

If I want to compile a personal library using this project everything seems ok. My systemjs demo is ok, but not webpack2 and angular-cli demos.

Using webpack2 with treeshaking (also without AOT in my demo project), compilation is ok, but I receive this error

Failed to load resource: the server responded with a status of 404 (Not Found)
Failed to load LIBRARY.scss

Using angular-cli, compilation is ok, but I receive this error

GET http://localhost:4200/LIBRARY.scss 404 (Not Found)
Unhandled Promise rejection: Failed to load LIBRARY.scss ; Zone: <root> ; Task: Promise.then ; Value: Failed to load LIBRARY.scss

The same problem happens with a templateUrl inside my library. If I use an external html file instead of an inline template I receive a similar error. It seems that relative paths cause these problems.

Could you confirm this?

Thanks

cankayacan commented 7 years ago

Hi, the starter already comes with an external template (sample.component.html) and external style (sample.component.scss) which are working fine actually. Is there an example that you can provide to me to reproduce the issue?

Ks89 commented 7 years ago

Hi. Thank you for your answer. I'll give you an example in couple of days, because at the moment I haven't enough spare time.

Ks89 commented 7 years ago

I found this project that it's really famous: https://github.com/AngularClass/angular2-webpack-starter

I tried to import you library without any modifications and It won't start.

I received this error:

GET http://localhost:3000/sample.component.html 404 (Not Found)
Failed to load sample.component.html

Removing the external HTML file, I received this error:

GET http://localhost:3000/sample.component.scss 404 (Not Found)
Failed to load sample.component.scss

The same problem happens with angular-cli since it based on webpack2 + treeshaking.

cankayacan commented 7 years ago

How do you reference ngx-library-starter in your package.json, with the git URL like this? "ngx-library-starter": "https://github.com/cankayacan/ngx-library-starter.git",

This will not use the bundled file but the webpack will bundle everything starting with index.ts on it's own and still working locally for me.

I have also published ngx-library-starter to the npm which is also working fine. "ngx-library-starter": "0.0.1",

I am using the latest angular2-webpack-starter. You can check the sample usage here.

Ks89 commented 7 years ago

Damn! You are right. I wrote a script to copy dist folder into my systemjs demo's node_modules, and I copied and pasted it also for webpack.

Thank you for you support. Issue closed.