Skip to content

Instantly share code, notes, and snippets.

@hannigand
Created October 6, 2017 08:55
Show Gist options
  • Save hannigand/606d8654fa8902153a602b3dc1717c30 to your computer and use it in GitHub Desktop.
Save hannigand/606d8654fa8902153a602b3dc1717c30 to your computer and use it in GitHub Desktop.
A simple Webpack config to build CSS, images and fonts.
const path = require('path');
module.exports = {
entry: './src/index.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
},
module: {
rules: [
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.(png|svg|jpg|gif)$/,
use: [
{
loader: 'file-loader',
options: {
outputPath: 'images/',
name: '[hash].[ext]',
},
},
{
loader: 'image-webpack-loader',
options: {
pngquant: {
quality: '65-90',
},
},
},
],
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/,
use: [
{
loader: 'file-loader',
options: {
outputPath: 'fonts/',
},
},
],
},
],
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment