我收到此错误
/home/ubuntu/workspace/node_modules/webpack/node_modules/webpack-core/lib/LoadersList.js:58
if(element.loader) return element.loader.split("!"); ^TypeError: element.loader.split is not a function
at getLoadersFromObject (/home/ubuntu/workspace/node_modules/webpack/node_modules/webpack-core/lib/LoadersList.js:58:43)
at LoadersList.<anonymous> (/home/ubuntu/workspace/node_modules/webpack/node_modules/webpack-core/lib/LoadersList.js:78:12)
at Array.map (native)
这是我的webpack
var webpack = require("webpack");
var path = require("path");
var ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry: {app: './src/app.js' },
output: {filename: 'public/build/bundle.js',
sourceMapFilename: 'public/build/bundle.map' },
module: {
loaders: [
{ test: /\.(js|jsx)$/, loader: 'babel-loader',query: {
presets: ['stage-0','react','es2015'],
plugins: ["transform-decorators-legacy","transform-class-properties"]
} },
{ test: /\.css$/, loaders: [ 'style-loader', 'css-loader' ] },
{ test: /\.(eot|svg|ttf|woff|woff2)$/, loader: 'file?name=public/fonts/[name].[ext]' },
{test: /\.(jpe?g|png|gif|svg)$/i, loaders: [
'file?hash=sha512&digest=hex&name=[hash].[ext]',
'image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false'
]}
]
}
}
答案 0 :(得分:1)
问题出在你最后一个装载机上。
$
它有一个数组,而不是一个字符串。 {test: /\.(jpe?g|png|gif|svg)$/i, loader: [
'file?hash=sha512&digest=hex&name=[hash].[ext]',
'image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false'
]}
需要一个字符串,loader
需要一个数组。将密钥更改为loaders
,复数:
loaders