Webpack.config.js没有使用加载器数组。

时间:2016-12-30 16:51:00

标签: webpack webpack-style-loader

有人在这里使用Webpack吗?我正在玩它并很早就遇到了问题。在附加的GIST中,我的webpack.config.js似乎并不想对任何包含的文件使用loaders数组。如果我内联装载机他们工作,但否则它告诉我我错过了装载机。有什么想法吗?

https://gist.github.com/coreysnyder/5e4b02ad11cf1ace52cceca59fb7045d

1 个答案:

答案 0 :(得分:1)

应该是module.loaders,而不是loaders

var webpack = require('webpack');

module.exports = {
  context: __dirname + '/app',
  module: {
    loaders: [
      {test: /\.css$/, loader: "style-loader!css-loader" },
      { test: /\.png$/, loader: "url-loader?limit=100000" },
      { test: /\.jpg$/, loader: "file-loader" },
      {test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/font-woff" },
      {test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/octet-stream" },
      {test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: "file" },
      {test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=image/svg+xml" },
      {test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "url-loader?limit=10000&mimetype=application/font-woff"},
      {test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,loader: "file-loader"}
    ],
  },
  entry: {
    app: ['./app.js', './app.css'],
    vendor: [
      'angular',
      'angular-route',
      'underscore',
      '!style-loader!css-loader!app.css', // This works fine as it's a simple 1 definition css file
      '!style-loader!css-loader!bootstrap/dist/css/bootstrap.css' // This blows up trying to process the font files
      'app.css',  // This doesn't work b/c `You may need an appropriate loader to handle this file type.`
      'bootstrap/dist/css/bootstrap.css' // This doesn't work b/c `You may need an appropriate loader to handle this file type.`
    ]
  },
  output: {
    path: __dirname + '/app/dist',
    filename: 'app.bundle.js',
    publicPath: '/dist'
  },
  plugins: [
    new webpack.optimize.CommonsChunkPlugin(/* chunkName= */"vendor", /* filename= */"vendor.bundle.js")
  ],
  devServer: {
    contentBase: "./app",
    hot: false
  }
};