webpack.config.dev.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /**
  2. * Created by magedu on 2017/4/20.
  3. */
  4. const path = require('path');
  5. const webpack = require('webpack');
  6. module.exports = {
  7. devtool: 'source-map',
  8. entry: {
  9. 'app': [
  10. 'react-hot-loader/patch',
  11. './src/index'
  12. ]
  13. },
  14. output: {
  15. path: path.join(__dirname, 'dist'),
  16. filename: 'bundle.js',
  17. publicPath: '/assets/'
  18. },
  19. resolve: {
  20. extensions: ['.js']
  21. },
  22. module: {
  23. rules: [
  24. {
  25. test: /\.js$/,
  26. exclude: /node_modules/,
  27. use: [
  28. { loader: 'react-hot-loader/webpack' },
  29. { loader: 'babel-loader' }
  30. ]
  31. },
  32. {
  33. test: /\.less$/,
  34. use: [
  35. { loader: "style-loader" },
  36. { loader: "css-loader" },
  37. { loader: "less-loader" }
  38. ]
  39. }
  40. ]
  41. },
  42. plugins: [
  43. new webpack.optimize.OccurrenceOrderPlugin(true),
  44. new webpack.HotModuleReplacementPlugin(),
  45. new webpack.DefinePlugin({'process.env': {NODE_ENV: JSON.stringify('development')}})
  46. ],
  47. devServer: {
  48. compress: true,
  49. port: 3000,
  50. publicPath: '/assets/',
  51. hot: true,
  52. inline: true,
  53. historyApiFallback: true,
  54. stats: {
  55. chunks: false
  56. },
  57. proxy: {
  58. '/api': {
  59. target: 'http://127.0.0.1:8080',
  60. changeOrigin: true
  61. }
  62. }
  63. }
  64. };