Skip to content

Instantly share code, notes, and snippets.

@eduardoreche
Created October 3, 2017 16:15
Show Gist options
  • Save eduardoreche/d95d6655bfe2e05d8ba12738a7cb790d to your computer and use it in GitHub Desktop.
Save eduardoreche/d95d6655bfe2e05d8ba12738a7cb790d to your computer and use it in GitHub Desktop.
Webpack config with file and image-webpack loaders
module.exports = {
entry: ['./src/index.js'],
output: {
path: __dirname,
publicPath: '/',
filename: 'bundle.js'
},
module: {
rules: [
{
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['react', 'es2015', 'stage-1']
}
},
{
test: /\.css$/,
use: ['css-loader']
},
{
test: /\.(gif|png|jpe?g|svg)$/i,
loaders: [
'file-loader?hash=sha512&digest=hex&name=[hash].[ext]',
{
loader: 'image-webpack-loader',
query: {
pngquant: { quality: '75-90', speed: 3 },
mozjpeg: { quality: 65 },
gifsicle: {
interlaced: false
},
optipng: {
optimizationLevel: 4
}
}
}
]
}
]
},
resolve: {
enforceExtension: false,
extensions: ['.js', '.jsx']
},
devServer: {
historyApiFallback: true,
contentBase: './'
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment