Skip to content

Images in template html / webpack problem #8

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
raczak opened this issue Apr 27, 2017 · 1 comment
Closed

Images in template html / webpack problem #8

raczak opened this issue Apr 27, 2017 · 1 comment

Comments

@raczak
Copy link

raczak commented Apr 27, 2017

Hello thx for your previous answer :) ,

I also have others issues :

I have a custom js script and unfortunately I need to reuse it in a template. How can I import it without using a : <script src="myscripts.js"></script> in the template.

The second problem is also related to the tempale : I want to know how can I display images in my template. For example in index.html I want to add a svg and a png image from my assets folder. But when I put the <img> tag with the correct path after a webpack --watch the image is not found. Webpack don't add my image to the dist folder. My assets are in src/assets.

Thank you by advance for your answer,

@maximegris
Copy link
Owner

maximegris commented Apr 27, 2017

Default webpack configuration don't process html and just load it as is.

There is actually an opened issue about using html-loader instead of raw-loader angular/angular-cli#5363

If you want to change webpack config, you have to install "html-loader" : npm install -D html-loaderand replace `:

      {
        "test": /\.html$/,
        "loader": ["raw-loader"]
      },

by

      {
        "test": /\.html$/,
        "loader": ["html-loader"]
      },

About your script, you need to:

  • add allowJs: true in tsconfig.ts
  • import './test.js' in àpp.component.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants