javascript - Very simple: requiring images in webpack and Angular 2 -


i having trouble requiring images in angular 2 webpack applicaiton.

i have tried 3 or 4 image loaders don't seem able configure them , result in html incorrect.

for example, @ moment have:

<img src='${require("../images/logo.png")}'> 

the file containing image part of template required this:

@component({     selector: 'appstore-app',     directives: [ ...router_directives ],     styles: [require('../sass/appstore.scss').tostring()],     template: require('./app.component.html') }) 

this results in error in browser:

get: http://localhost:8080/$%7brequire(%22../images/logo.png%22)%7d  

my loader images image webpack.config.js looks this:

{ test: /\.(png|jpg|gif)$/, loader: "url-loader?limit=50000&name=[path][name].[ext]" } 

i may muddling syntaxes here i've said i've tried few methods. doesn't work. $require makes html verbatim without being transformed!

how either copy images build folder or package them dataurl?

please help!

you should so. know figured out future reference don't need use require; use ____url instead. require caused me issues other libraries using webpack loading assets....it's not needed.

     <img src="../images/logo.png">  //note styleurl , templateurl since have path not inline component         @component({             selector: 'appstore-app',             directives: [ ...router_directives ],             styleurl: ['../sass/appstore.scss'],             templateurl: './app.component.html'         }) 

Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -