Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将iconfont网页包插件与Laravel Mix一起使用_Laravel_Webpack - Fatal编程技术网

将iconfont网页包插件与Laravel Mix一起使用

将iconfont网页包插件与Laravel Mix一起使用,laravel,webpack,Laravel,Webpack,我是webpack新手,正在尝试向Laravel项目添加自定义图标字体生成器。ICont库位于,并添加到webpack.config.js,如下所示: const IconfontWebpackPlugin = require('iconfont-webpack-plugin'); module: { rules: [ { test: /\.css$/, use: [ 'css-loader', {

我是webpack新手,正在尝试向Laravel项目添加自定义图标字体生成器。ICont库位于,并添加到webpack.config.js,如下所示:

const IconfontWebpackPlugin = require('iconfont-webpack-plugin');

  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          'css-loader',
          {
            loader: 'postcss-loader',
            postcssOptions: (loader) => {
              return {
                plugins: [
                  new IconfontWebpackPlugin({
                    resolve: loader.resolve,
                    fontNamePrefix: 'custom-',
                    enforcedSvgHeight: 3000,
                  })
                ]
              };
            }
          }
        ]
      }
    ]
  }
const IconfontWebpackPlugin = require('iconfont-webpack-plugin');

mix.webpackConfig({
    module: {
        rules: [
            {
                test: /\.css$/,
                use: [
                    'css-loader',
                    {
                        loader: 'postcss-loader',
                        postcssOptions: (loader) => {
                            return {
                                plugins: [
                                    new IconfontWebpackPlugin({
                                        resolve: loader.resolve,
                                        fontNamePrefix: 'custom-',
                                        enforcedSvgHeight: 3000,
                                    })
                                ]
                            };
                        }
                    }
                ]
            }
        ]
    }
});
在中,我使用
mix.webpackConfig()
函数,如下所示:

const IconfontWebpackPlugin = require('iconfont-webpack-plugin');

  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          'css-loader',
          {
            loader: 'postcss-loader',
            postcssOptions: (loader) => {
              return {
                plugins: [
                  new IconfontWebpackPlugin({
                    resolve: loader.resolve,
                    fontNamePrefix: 'custom-',
                    enforcedSvgHeight: 3000,
                  })
                ]
              };
            }
          }
        ]
      }
    ]
  }
const IconfontWebpackPlugin = require('iconfont-webpack-plugin');

mix.webpackConfig({
    module: {
        rules: [
            {
                test: /\.css$/,
                use: [
                    'css-loader',
                    {
                        loader: 'postcss-loader',
                        postcssOptions: (loader) => {
                            return {
                                plugins: [
                                    new IconfontWebpackPlugin({
                                        resolve: loader.resolve,
                                        fontNamePrefix: 'custom-',
                                        enforcedSvgHeight: 3000,
                                    })
                                ]
                            };
                        }
                    }
                ]
            }
        ]
    }
});
这是一个生成错误:

Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
 - configuration.module.rules[12].use[1] has an unknown property 'postcssOptions'. These properties are valid:
   object { ident?, loader?, options? }
在Laravel Mix中,正确的方法是什么