1

I'm using ngx-leaflet with webpack 4 and I'm having a problem displaying the layers control image. The default marker icons show up fine since I'm using import iconname from 'leaflet/dist/images/layers.png' etc using the file-loader. The project does not use the CLI and uses standalone webpack 4. If I take same code and use it in an angular CLI project the icon shows up fine after following the asset configuration in the Angular CLI Marker Workaround section. What am I missing? What do I need to have this icon show up without using the CLI? I get no errors in the developer tools and the layers.png seems to be requested in the network traffic.

Here is the webpack config:

"use strict";

var path = require('path');
var webpack = require('webpack');

var ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
var HappyPack = require('happypack');

module.exports = {
    mode: 'development',
    devtool: 'inline-source-map',
    entry:
            {
                polyfills: './src/polyfills.ts',                
                app: './src/main.ts'
            },
    output:
            {
                filename: '[name].js',
                chunkFilename: '[name]-chunk.js',
                publicPath: './dist/',
                path: path.resolve(__dirname, 'dist')
            },
    module: {
        rules: [              
              {
                  test: /\.html$/,
                  use: 'raw-loader'
              },
              {
                  test: /\.tsx?$/,
                  loaders: [
                            {
                                loader: 'cache-loader'
                            },
                            {
                                loader: 'happypack/loader'
                            },
                            {
                                loader: 'angular-router-loader'
                            }
                            ]
              },
              {
                  test: /\.(png|jpg|svg)$/,
                  use:
                  [
                      {
                          loader: 'file-loader',
                          options: 
                              {
                                  name: '[name].[ext]',
                                  outputPath: 'assets/'
                              }
                      }
                  ]
              }              
        ]
    },    
    plugins: [
                new webpack.ContextReplacementPlugin(/\@angular(\\|\/)core(\\|\/)esm5/, path.join(__dirname, './src')),
                new ForkTsCheckerWebpackPlugin({}),
                new HappyPack({
                    threads: 2,
                    loaders:
                        [
                            {
                                loader: 'ts-loader',
                                options: { transpileOnly: true, happyPackMode: true }
                            }
                        ]
                })        
    ]    
};
jurgen w
  • 243
  • 1
  • 2
  • 14

0 Answers0