找不到Webpack字体

时间:2016-07-26 16:31:30

标签: javascript angularjs fonts webpack

我开始学习webpack,我有这个小项目

为简洁起见,我将简化内容,希望它不会影响您对问题的理解。

.
└── project
    ├── dist
    │   ├── fonts
    │   └── js
    ├── src
    │   ├── app
    │   │   ├── app.js
    │   │   └── component
    │   │       ├── component.css
    │   │       ├── component.directive.js
    │   │       └── component.html
    │   └── fontello
    ├── index.html
    ├── package.json
    └── webpack.config.js

我正在尝试将所有内容保存在我的组件中,所以我有:

component.directive.js

require('../../fontello/css/fontello.css');
require('./component.css');

var angular = require('angular');

...

module.exports = angular.module('directives.component', [])
    .directive('component', component)
    .name;

app.js

var angular = require('angular');   
var component = require('./component/component.directive.js');

...

angular.module('app', [component])

和webpack.config.js

var webpack = require('webpack');

module.exports = {
    context: __dirname + '/src',
    entry: {
        app: './app/app.js',
        vendor: ['angular']
    },
    output: {
        path: __dirname + '/dist',
        filename: 'js/app.bundle.js'
    },
    plugins: [
        new webpack.optimize.CommonsChunkPlugin("vendor", "js/vendor.bundle.js")
    ],
    module: {
        loaders: [{
            test: /\.css$/,
            loader: 'style-loader!css-loader',
            exclude: ['./src/fontello']
        }, {
            test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)(\?[a-z0-9=&.]+)?$/,
            loader: 'file-loader?name=fonts/[name].[ext]'
        }, {
            test: /\.html$/,
            loader: 'raw'
        }]
    }
};

我得到了woff2 / woff / ttf

  

404 Not Found。获取http://localhost:8080/fonts/fontello.woff2

我做错了什么?

0 个答案:

没有答案