1

I am using Angular2 and Webpack and have the following piece of code within a typescript file.

    private getIcon = (dataItem) => {

        var src = "./images/myImage.png";
        if (dataItem.url && dataItem.url != "") {
            src = "data:image/png;base64," + dataItem.url;
        }

        var icon = new this.diagram.Image({
            width: 80,
            height: 80,
            y: 15,
            source: src
        });

        return icon;
    }

In my webpack.config.js I have the following loaders specified,

          {
          test: /\.ts$/,
          loaders: ['awesome-typescript-loader', 'angular2-template-loader']
          },
          {
              test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
              loader: 'file?name=assets/[name].[hash].[ext]'
          }

This loader however only seems to change the paths for the images referenced in a html markup. Is there any way I could use rewrite the paths for the static assets I use within my typescript code files?

lohiarahul
  • 1,432
  • 3
  • 22
  • 35

0 Answers0