使用webpack字体错误构建开放标志性错误

时间:2018-06-11 21:52:35

标签: webpack fonts webpack-4

尝试使用webpack构建开放式图标时出错4.如果有人有样板或其他东西 - 请链接它。到目前为止,我试着看一下 https://github.com/laboradian/webpack3-bootstrap4-open-iconic-sample001 存储库,但没有运气。

所以,我无法加载字体文件 - ttf,eot,woff等。我之前使用bootstrap和font-awesome解决了这些问题,但我无法弄清楚我的情况有什么问题。

client:161 ./node_modules/open-iconic/font/fonts/open-iconic.ttf
Module parse failed: Unexpected character '
You may need an appropriate loader to handle this file type.

这是我的webpack.config

const path = require('path')
const webpack = require('webpack')
const HtmlWebPackPlugin = require('html-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')

const DEV_MODE = process.env.NODE_ENV === 'dev'

module.exports = {
  devtool: DEV_MODE ? 'eval' : 'source-map',
  entry: './src/index.js',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: '[name].js'
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'babel-loader'
      },
      DEV_MODE
        ? {
            test: /\.scss/,
            use: [
              'style-loader',
              {
                loader: 'css-loader',
                options: {
                  sourceMap: true
                }
              },
              {
                loader: 'sass-loader',
                options: {
                  sourceMap: true
                }
              }
            ]
          }
        : {
            test: /\.scss$/,
            use: ExtractTextPlugin.extract({
              fallback: 'style-loader',
              use: ['css-loader', 'sass-loader']
            })
          },
      {
        test: /\.(jpe?g|png|gif)$/,
        loader: 'file-loader',
        options: {
          name: '[path][name].[ext]'
        }
      },
      { test: /\.(woff|woff2|eot|ttf|otf)$/, use: ['url-loader'] }
    ]
  },
  plugins: [
    new webpack.ProvidePlugin({
      $: 'jquery',
      jQuery: 'jquery'
    }),
    new HtmlWebPackPlugin({
      template: 'index.html'
    }),
    new ExtractTextPlugin('styles.css')
  ]
}

导入saas:

$icon-font-path: '../../node_modules/open-iconic/font/fonts/';
@import '../../node_modules/open-iconic/font/css/open-iconic-bootstrap.scss';

0 个答案:

没有答案