Only add the main javascript files as entries and require all fonts and style via require('./style.css')
webpack.config.js:
entry: {
'main': 'app/main',
},
output: {
path: 'static',
publicPath: '/static/',
filename: '[name].bundle.js',
chunkFilename: '[chunkhash].bundle.js',
},
module: {
rules: [
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader'
}),
}]
},
plugins: [
new ExtractTextPlugin('[name].bundle.css'),
],
That would give you a /static/main.bundle.css
with all css (transitively) included from your app/main.js.
Same for fonts, but you would need a second ExtractTextPlugin instance like:
const extractCSS = new ExtractTextPlugin('stylesheets/[name].bundle.css');
const extractFonts = new ExtractTextPlugin('stylesheets/[name].bundle.woff');
module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: extractCSS.extract([ 'css-loader', 'postcss-loader' ])
},
{
test: /\.woff$/i,
use: extractFonts.extract([ 'url-loader' ])
},
]
},
plugins: [
extractCSS,
extractFonts
]
};
See the Documentation - Multiple Instances for more info about that.