I have a problem with getting my mp3 files to work using the webpack file loader.
This is the issue:
I have a mp3 file on my harddisk, that if I open using c
https://stackoverflow.com/a/41158166/11878375 - it's correctly answer, but define SRC like this:
var path = require('path');
var SRC = path.resolve(__dirname, 'src/main/js');
For example, I am using react-chat-ui with webpack and this is my webpack.config.js:
const path = require('path');
const SRC = path.resolve(__dirname, 'node_modules');
module.exports = {
entry: './jsx/App.jsx',
mode: "development",
output: {
path:
'/java/helios-backend/src/main/resources/static/js'
// __dirname + '/js/'
,
filename: 'bundle.js'
},
devtool: '#sourcemap',
stats: {
colors: true,
reasons: true
},
module: {
rules: [
{ test: /\.css$/, loader: 'style-loader!css-loader' },
{
test: /\.jsx?$/,
exclude: /(node_modules)/,
loaders: ['babel-loader']
},
{
test: /\.(gif|png|jpe?g|svg)$/i,
use: [
'file-loader',
{
loader: 'image-webpack-loader',
options: {
bypassOnDebug: true,
disable: true,
},
},
]},
{
test: /\.mp3$/,
include: SRC,
loader: 'file-loader'
}
]
}
};
And do not forget to install the file-loader before:
npm install file-loader --save-dev