Created
October 3, 2017 16:15
-
-
Save eduardoreche/d95d6655bfe2e05d8ba12738a7cb790d to your computer and use it in GitHub Desktop.
Webpack config with file and image-webpack loaders
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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