webpack.config.js.production 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. const HtmlWebpackPlugin = require('html-webpack-plugin');
  2. const path = require('path');
  3. module.exports = {
  4. entry: './src/index.js',
  5. plugins: [new HtmlWebpackPlugin(
  6. {
  7. template: 'home.html'
  8. }
  9. )],
  10. output: {
  11. filename: '[name].bundle.js',
  12. path: path.resolve(__dirname, 'dist'),
  13. },
  14. module: {
  15. rules: [
  16. {
  17. test: /\.css$/,
  18. use: ['style-loader', 'css-loader'],
  19. },
  20. {
  21. test: /path\.txt/,
  22. use: ['file-loader'],
  23. },
  24. {
  25. test: /\.(js|jsx)$/,
  26. exclude: /node_modules/,
  27. use: {
  28. loader: 'babel-loader'
  29. }
  30. },
  31. ],
  32. },
  33. resolve: {
  34. extensions: [".js", ".jsx"]
  35. },
  36. mode: 'production',
  37. performance: {
  38. hints: false,
  39. maxEntrypointSize: 512000,
  40. maxAssetSize: 512000
  41. },
  42. devServer:{
  43. compress: false,
  44. port: 9002,
  45. static: './dist'
  46. },
  47. optimization: {
  48. runtimeChunk: 'single',
  49. splitChunks: {
  50. cacheGroups: {
  51. vendor1: {
  52. test: /[\\/]node_modules[\\/](r.*|s.*|t.*|u.*|v.*|w.*|x.*|y.*|z.*)[\\/]/,
  53. name: 'vendors1',
  54. chunks: 'all'
  55. },
  56. vendor2: {
  57. test: /[\\/]node_modules[\\/](a.*|b.*|c.*|d.*|e.*|f.*|g.*|h.*|i.*)[\\/]/,
  58. name: 'vendors2',
  59. chunks: 'all'
  60. },
  61. },
  62. },
  63. }
  64. };