2016-12-13 89 views
0

我想包括與webpack的字體真棒。下面錯誤,包括與webpack的字體真棒

import 'font-awesome/css/font-awesome.css'; 

require('font-awesome/css/font-awesome.css') 

產生以下錯誤

ERROR in multi vendor 
Module not found: Error: Can't resolve 'font-awesome' in '...' 
@ multi vendor 

的哪些錯誤? font-awesome是我使用fountain.io已經安裝

,全面的WebPack配置是這樣的:

const webpack = require('webpack'); 
const conf = require('./gulp.conf'); 
const path = require('path'); 

const HtmlWebpackPlugin = require('html-webpack-plugin'); 
const ExtractTextPlugin = require('extract-text-webpack-plugin'); 
const pkg = require('../package.json'); 
const autoprefixer = require('autoprefixer'); 

module.exports = { 
    module: { 
    preLoaders: [ 
     { 
     test: /\.js$/, 
     exclude: /node_modules/, 
     loader: 'eslint' 
     } 
    ], 

    loaders: [ 
     { 
     test: /.json$/, 
     loaders: [ 
      'json' 
     ] 
     }, 
     { 
     test: /\.(css|less)$/, 
     loaders: ExtractTextPlugin.extract({ 
      fallbackLoader: 'style', 
      loader: 'css?minimize!less!postcss' 
     }) 
     }, 
     { 
     test: /\.js$/, 
     exclude: /node_modules/, 
     loaders: [ 
      'ng-annotate' 
     ] 
     }, 
     { 
     test: /.html$/, 
     loaders: [ 
      'html' 
     ] 
     } 
    ] 
    }, 
    plugins: [ 
    new webpack.optimize.OccurrenceOrderPlugin(), 
    new webpack.NoErrorsPlugin(), 
    new HtmlWebpackPlugin({ 
     template: conf.path.src('index.html') 
    }), 
    new webpack.optimize.UglifyJsPlugin({ 
     compress: {unused: true, dead_code: true, warnings: false} // eslint-disable-line camelcase 
    }), 
    new ExtractTextPlugin('index-[contenthash].css'), 
    new webpack.optimize.CommonsChunkPlugin({name: 'vendor'}) 
    ], 
    postcss:() => [autoprefixer], 
    output: { 
    path: path.join(process.cwd(), conf.paths.dist), 
    filename: '[name]-[hash].js' 
    }, 
    entry: { 
    app: `./${conf.path.src('index')}`, 
    vendor: Object.keys(pkg.dependencies) 
    } 
}; 

回答

4

所以字體真棒沒有一個Javascript組件。其結果是,當你包括在你這樣的切入點定義:

entry: { app: `./${conf.path.src('index')}`, vendor: Object.keys(pkg.dependencies) }

沒有包找到。嘗試調整您的供應商定義,例如

vendor: Object.keys(pkg.dependencies).filter(name => (name != 'font-awesome'))

進口/需要main.js的說法應該是足以引起裝載機,包括必要的文件。

+0

這只是幫助我!標記爲正確的答案:)! –