webpack.config.prod.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. var webpack = require('webpack');
  2. var path = require('path');
  3. var ExtractTextPlugin = require('extract-text-webpack-plugin');
  4. var HtmlWebpackPlugin = require('html-webpack-plugin');
  5. var FaviconsWebpackPlugin = require('favicons-webpack-plugin');
  6. module.exports = {
  7. entry: [
  8. './src/index.js'
  9. ],
  10. devtool: 'source-map',
  11. output: {
  12. path: path.join(__dirname, 'dist'),
  13. filename: 'bundle.js'
  14. },
  15. resolve: {
  16. extensions: ['', '.js', '.jsx'],
  17. alias: {
  18. 'react': 'preact-compat',
  19. 'react-dom': 'preact-compat',
  20. 'flags.css' : path.join(__dirname, 'node_modules/flag-icon-css/css/flag-icon.min.css')
  21. }
  22. },
  23. module: {
  24. loaders: [{
  25. test: /\.jsx?$/,
  26. exclude: /(node_modules)/,
  27. loaders: ['babel']
  28. }, {
  29. test: /\.css$/,
  30. loader: ExtractTextPlugin.extract('style-loader', 'css-loader')
  31. }, {
  32. test: /\.scss$/,
  33. loaders: ['style', 'css', 'autoprefixer?browsers=last 2 versions',
  34. "sass?outputStyle=expanded&"
  35. ]
  36. },{
  37. test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
  38. loader: "file"
  39. }, {
  40. test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
  41. loader: "url-loader?limit=10000&mimetype=application/font-woff"
  42. }, {
  43. test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
  44. loader: "url?limit=10000&mimetype=application/octet-stream"
  45. }, {
  46. test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
  47. loader: "url?limit=10000&mimetype=image/svg+xml"
  48. }, {
  49. test: /\.gif/,
  50. loader: "url-loader?limit=10000&mimetype=image/gif"
  51. }, {
  52. test: /\.jpg/,
  53. loader: "url-loader?limit=10000&mimetype=image/jpg"
  54. }, {
  55. test: /\.png/,
  56. loader: "url-loader?limit=10000&mimetype=image/png"
  57. },{
  58. test : /\.json/,
  59. loader: "json-loader"
  60. }
  61. ]
  62. },
  63. plugins: [
  64. new ExtractTextPlugin('bundle.css'),
  65. new HtmlWebpackPlugin({
  66. title : 'Rate-It',
  67. template : './template/index.ejs',
  68. inject: false
  69. }),
  70. new webpack.optimize.UglifyJsPlugin({
  71. compress: { warnings: false },
  72. comments: false,
  73. minimize: false,
  74. sourceMap : true
  75. }),
  76. new webpack.optimize.AggressiveMergingPlugin(),
  77. new webpack.DefinePlugin({
  78. 'process.env.NODE_ENV': '"production"'
  79. }),
  80. new FaviconsWebpackPlugin('./images/favicon.png')
  81. ]
  82. };