Actually the main link of example is this link and the stable version of it will be always here.
For your exact answer you can use below code to import the file-loader
for all media:
{
test: /\.(woff|woff2|eot|ttf|svg)$/,
exclude: /node_modules/,
loader: 'file-loader',
options: {
limit: 1024,
name: '[name].[ext]',
publicPath: 'font/',
outputPath: 'font/'
}
},
{
test: /\.(jpg|png)$/,
exclude: /node_modules/,
loader: 'file-loader',
options: {
limit: 1024,
name: '[name].[ext]',
publicPath: 'img/',
outputPath: 'img/'
}
}
After this setting you can access to your media by using this these addresses:
CSS
:
background: url('./img/myMedia.jpg');
@font-face {
font-family: 'as-you-wish';
src: url('./font/yourFont.eot');
}
DOM
:
<img src='/dist/img/myMedia.jpg' />
But remember this config is in rule:
after the second object, so your result config must be like these:
module: {
rules: [
{
test: /\.(js|jsx|jss)$/,
exclude: /(node_modules[\/\\])(?!mqtt)/,
use: [
{
loader: 'babel-loader',
},
{
loader: 'shebang-loader',
}
]
},
{
test: /\.pcss$/,
exclude: /(node_modules\/)/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: {
modules: true,
importLoaders: 1,
localIdentName: '[local]',
sourceMap: true,
}
},
{
loader: 'postcss-loader',
options: {
config: {
path: `${__dirname}/../postcss/postcss.config.js`,
}
}
}
]
})
},
{
test: /\.(woff|woff2|eot|ttf|svg)$/,
exclude: /node_modules/,
loader: 'file-loader',
options: {
limit: 1024,
name: '[name].[ext]',
publicPath: 'font/',
outputPath: 'font/'
}
},
{
test: /\.(jpg|png)$/,
exclude: /node_modules/,
loader: 'file-loader',
options: {
limit: 1024,
name: '[name].[ext]',
publicPath: 'img/',
outputPath: 'img/'
}
}
],
}
So after it pay attention to [name].[ext]
in name:
, I change it to [hash:base64:5].[ext]
for production version.
For any issues, leave an issue message in Github repo.