图层控件不可见Webpack 4

时间:2018-05-12 02:04:07

标签: webpack ngx-leaflet

我正在使用带有webpack 4的ngx-leaflet,我在显示图层控件图像时遇到问题。默认标记图标显示正常,因为我使用文件加载器从'leaflet / dist / images / layers.png'等使用导入iconname。该项目不使用CLI并使用独立的webpack 4.如果我使用相同的代码并在角度CLI项目中使用它,那么在遵循Angular CLI Marker Workaround部分中的资产配置后,图标会显示正常。我错过了什么?在不使用CLI的情况下,如何显示此图标需要什么?我在开发人员工具中没有错误,而且似乎在网络流量中请求了layers.png。

这是webpack配置:

"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 }
                            }
                        ]
                })        
    ]    
};

0 个答案:

没有答案