webpack.pro.config.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. const { resolve } = require('path');
  2. const webpack = require('webpack');
  3. module.exports = {
  4. context: __dirname,
  5. entry: [
  6. // 'react-hot-loader/patch',
  7. // 'webpack/hot/only-dev-server',
  8. './app/src/index.js'
  9. ],
  10. output: {
  11. path: resolve(__dirname, 'build'),//打包后的文件存放的地方
  12. filename: "bundle.js",//打包后输出文件的文件名
  13. publicPath: "/"
  14. },
  15. devServer: {
  16. contentBase: resolve(__dirname, 'build'),
  17. hot: true,
  18. publicPath: '/',
  19. },
  20. module: {
  21. rules: [
  22. {
  23. test: /\.jsx?$/,
  24. use: [
  25. 'babel-loader',
  26. ],
  27. exclude: /node_modules/
  28. },
  29. {
  30. test: /\.css$/,
  31. use: [
  32. 'style-loader', 'css-loader'
  33. ],
  34. exclude: /node_modules/
  35. },
  36. ],
  37. },
  38. plugins: [
  39. new webpack.HotModuleReplacementPlugin(),
  40. new webpack.NamedModulesPlugin(),
  41. new webpack.optimize.UglifyJsPlugin({
  42. compress: {
  43. warnings: false
  44. }
  45. }),
  46. new webpack.DefinePlugin({
  47. 'process.env': {
  48. NODE_ENV: JSON.stringify(process.env.NODE_ENV),
  49. },
  50. }),
  51. ],
  52. // devtool: "cheap-eval-source-map",
  53. };