webpack.config.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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: 'eval',
  12. output: {
  13. path: path.join(__dirname, 'dist'),
  14. filename: 'bundle.js'
  15. },
  16. resolve: {
  17. extensions: ['', '.js', '.jsx', '.css'],
  18. modules: ['node_modules', 'src'],
  19. alias : {
  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', TranslationPlugin.loader({
  28. path :path.join(__dirname, "config/locales/generated")
  29. })]
  30. }, {
  31. test: /\.css$/,
  32. loader: ExtractTextPlugin.extract('style-loader', 'css-loader')
  33. }, {
  34. test: /\.scss$/,
  35. loaders: ['style', 'css', 'postcss-loader',
  36. "sass?outputStyle=expanded&"
  37. ]
  38. },{
  39. test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
  40. loader: "file"
  41. }, {
  42. test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
  43. loader: "url-loader?limit=10000&mimetype=application/font-woff"
  44. }, {
  45. test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
  46. loader: "url?limit=10000&mimetype=application/octet-stream"
  47. }, {
  48. test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
  49. loader: "url?limit=10000&mimetype=image/svg+xml"
  50. }, {
  51. test: /\.gif/,
  52. loader: "url-loader?limit=10000&mimetype=image/gif"
  53. }, {
  54. test: /\.jpg/,
  55. loader: "url-loader?limit=10000&mimetype=image/jpg"
  56. }, {
  57. test: /\.png/,
  58. loader: "url-loader?limit=10000&mimetype=image/png"
  59. },{
  60. test : /\.json/,
  61. loader: "json-loader"
  62. }
  63. ]
  64. },
  65. devServer: {
  66. contentBase: "./dist",
  67. hot: true,
  68. inline: true,
  69. port: 3000,
  70. historyApiFallback: true
  71. },
  72. plugins: [
  73. new webpack.NoErrorsPlugin(),
  74. new webpack.HotModuleReplacementPlugin(),
  75. new ExtractTextPlugin('bundle.css'),
  76. new HtmlWebpackPlugin({
  77. title : 'Rate-It',
  78. template : './template/index.ejs',
  79. inject: false
  80. }),
  81. new FaviconsWebpackPlugin('./images/favicon.png'),
  82. new webpack.DefinePlugin({
  83. 'process.env.NODE_ENV': JSON.stringify('development')
  84. }),
  85. new TranslationPlugin({
  86. path : path.join(__dirname, "config/locales/generated"),
  87. output : path.join(__dirname, "config/locales"),
  88. lang : "en"
  89. })
  90. ]
  91. };