第一次加载成功,但是一刷新页面图片就报错。
img标签
<img src={require('./style/ydg_logo.jpg')} alt="云东购logo" />
webpack.config.js
var path = require('path');
var webpack = require('webpack');
module.exports = {
devtool: 'cheap-module-eval-source-map',
devtool:false,
entry: [
'webpack-hot-middleware/client',
'./client/index'
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js',
publicPath: '/static/'
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
compress: {
//supresses warnings, usually from module minification
warnings: false
}
}),
new webpack.DefinePlugin({
'process.env':{
'NODE_ENV': JSON.stringify('production')
}
}),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
__SERVER__: false
})
],
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/,
include: __dirname,
query: {
presets: [ 'react-hmre' ]
}
},
{
test: /\.css?$/,
loaders: [ 'style', 'raw' ],
include: __dirname
},
{ test: /\.(jpeg|jpg|png|gif)$/,
loader: 'url-loader?limit=10240' },
]
}
};