Reputation: 3
I'm trying to get an image into my dist folder but it's not showing up.
I've included the copy-webpack-plugin which is what I thought would make it work. I do get a warning message during the build that says: 'WARNING in unable to locate '/Users/developer/Desktop/RecruitsPro/client/public' at '/Users/developer/Desktop/RecruitsPro/client/public'
webpack.config.js
var webpack = require('webpack');
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
const helpers = require('./helpers');
const VENDOR_LIBS = [
'axios',
'ordinal',
'react',
'react-activity',
'react-avatar',
'react-dom',
'react-easy-chart',
'react-is',
'react-modal',
'react-redux',
'react-router-dom',
'react-stripe-checkout',
'react-window-size',
'redux',
'redux-form',
'redux-thunk'
];
module.exports = {
entry: {
bundle: './client/app/index.js',
vendor: VENDOR_LIBS
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].[chunkhash].js'
},
module: {
rules: [
{
use: 'babel-loader',
test: /\.js$/,
exclude: /node_modules/
},
{
use: ['style-loader', 'css-loader'],
test: /\.css$/
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: './client/public/index.html'
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}),
new CopyWebpackPlugin([{
from: helpers.root('client/public')
}])
]
};
helpers.js
const path = require('path');
// Helper functions
function root(args) {
args = Array.prototype.slice.call(arguments, 0);
return path.join.apply(path, [__dirname].concat('../', ...args));
}
exports.root = root;
I was expecting the picture to show up.
Upvotes: 0
Views: 484
Reputation: 3
For anyone who's curious I had to add this code to my module.rules array.
{
test: /\.png$/,
loader: 'file-loader'
}
Upvotes: 0