webpack.config.prod.js 2.7 KB

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