webpack运行时的错误url-loader

时间:2016-06-07 13:30:10

标签: webpack

我正在尝试将url-loader与webpack一起使用,但它无法正常工作。

我的webpack.config.js

var path = require('path')
var webpack = require('webpack')
var BundleTracker = require('webpack-bundle-tracker')

module.exports = {

    context: __dirname,
    entry: [
        './assets/js/index'
    ], 

    output: {
        path: path.resolve('./assets/bundles/'), 
        filename: '[name].js'
    },

    devtool: 'inline-eval-cheap-source-map',

    plugins: [
        new BundleTracker({filename: './webpack-stats.json'})
    ],

    module: {
        loaders: [
            {
                test: /\.css$/,
                loader: "style-loader!css-loader"
            },

            {
                test: /\.jsx?$/, 
                exclude: /node_modules/, 
                loaders: "babel-loader"
            },
            {
                test: /\.png$/,
                exclude: /node_modules/,
                loader: "url-loader"
            }
        ]
    },

    resolve: {
        modulesDirectories: ['node_modules'],
        extensions: ['', '.js', '.jsx'] 
    }   
}

当我运行webpack时出现此错误:

/usr/src/app/node_modules/webpack/node_modules/webpack-core/lib/LoadersList.js:81
        r.forEach(function(r) {
          ^
TypeError: undefined is not a function
    at /usr/src/app/node_modules/webpack/node_modules/webpack-core/lib/LoadersList.js:81:5
    at Array.reduce (native)
    at LoadersList.match (/usr/src/app/node_modules/webpack/node_modules/webpack-core/lib/LoadersList.js:80:27)
    at /usr/src/app/node_modules/webpack/lib/NormalModuleFactory.js:111:68
    at /usr/src/app/node_modules/webpack/node_modules/async/lib/async.js:726:13
    at /usr/src/app/node_modules/webpack/node_modules/async/lib/async.js:52:16
    at done (/usr/src/app/node_modules/webpack/node_modules/async/lib/async.js:246:17)
    at /usr/src/app/node_modules/webpack/node_modules/async/lib/async.js:44:16
    at /usr/src/app/node_modules/webpack/node_modules/async/lib/async.js:723:17
    at /usr/src/app/node_modules/webpack/node_modules/async/lib/async.js:167:37
    at /usr/src/app/node_modules/webpack/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:29:4
    at onResolved (/usr/src/app/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:39:10)
    at /usr/src/app/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:123:21
    at /usr/src/app/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:191:15
    at applyPluginsParallelBailResult.createInnerCallback.log (/usr/src/app/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:104:30)
    at loggingCallbackWrapper (/usr/src/app/node_modules/webpack/node_modules/enhanced-resolve/lib/createInnerCallback.js:21:19)
    at /usr/src/app/node_modules/webpack/node_modules/tapable/lib/Tapable.js:134:6
    at innerCallback (/usr/src/app/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:90:37)
    at loggingCallbackWrapper (/usr/src/app/node_modules/webpack/node_modules/enhanced-resolve/lib/createInnerCallback.js:21:19)
    at /usr/src/app/node_modules/webpack/node_modules/tapable/lib/Tapable.js:134:6
    at Tapable.<anonymous> (/usr/src/app/node_modules/webpack/node_modules/enhanced-resolve/lib/DirectoryDescriptionFileFieldAliasPlugin.js:101:26)
    at /usr/src/app/node_modules/webpack/node_modules/enhanced-resolve/lib/DirectoryDescriptionFileFieldAliasPlugin.js:52:26
    at Storage.finished (/usr/src/app/node_modules/webpack/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:38:16)
    at /usr/src/app/node_modules/webpack/node_modules/enhanced-resolve/node_modules/graceful-fs/graceful-fs.js:78:16
    at fs.js:334:14
    at /usr/src/app/node_modules/webpack/node_modules/enhanced-resolve/node_modules/graceful-fs/graceful-fs.js:43:10
    at FSReqWrap.oncomplete (fs.js:95:15)

我的babel-loader,css-loader和style-loader工作正常。

我从文件夹和webpack.config中删除了我的svg图像以尝试解决问题,但它没有用。

0 个答案:

没有答案