webpack css loader svg和png

时间:2018-05-02 10:36:23

标签: javascript webpack

我有下一个webpack配置。

 plugins: [
        new CleanWebpackPlugin(['dist']),
        new HtmlWebpackPlugin()

    ],
    module: {
     rules: [
         {
             test: /\.css$/,
             use: [
                 'style-loader',
                 'css-loader'
             ]

         }
         ],
        loaders: [
            {
                test: /\.js$/,
                loader: 'babel-loader',
                query: {
                    presets: ['es2015']
                },
                exclude: /node_modules/
            },

构建webpack后,我收到一个错误: 您可能需要一个合适的加载程序来处理此文件类型。 在svg字符串中,它来自css文件。怎么能解决这个问题呢?

1 个答案:

答案 0 :(得分:0)

添加 //Calculate totalPremium String premium = order.getProposalId(); String proposal = order.getProposalId(); if(premium.equalsIgnoreCase("")){ premium = "0"; } if(proposal.equalsIgnoreCase("")){ proposal = "0"; } int total = 0; for (Order order:cart) total+=(Integer.parseInt(premium))* (Integer.parseInt(proposal)); Locale locale = new Locale("sw", "KE"); NumberFormat fmt = NumberFormat.getCurrencyInstance(locale); txtTotalPrice.setText(fmt.format(total)); url-loader来处理这些扩展程序。

file-loader

(摘自https://github.com/akx/demystifying-webpack/blob/162137118dd54f30a6c98dd0ae8844dba733483e/webpack.config.js#L13-L16