webpack.dev.babel.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /**
  2. * DEVELOPMENT WEBPACK CONFIGURATION
  3. */
  4. const path = require('path')
  5. const webpack = require('webpack')
  6. const HtmlWebpackPlugin = require('html-webpack-plugin')
  7. const CircularDependencyPlugin = require('circular-dependency-plugin')
  8. const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
  9. module.exports = require('./webpack.base.babel')({
  10. mode: 'development',
  11. // Add hot reloading in development
  12. entry: {
  13. app: [
  14. 'webpack-hot-middleware/client?reload=true',
  15. path.join(process.cwd(), 'app/app.tsx') // Start with js/app.js
  16. ],
  17. share: [
  18. 'webpack-hot-middleware/client?reload=true',
  19. path.join(process.cwd(), 'share/app.tsx')
  20. ]
  21. },
  22. // Don't use hashes in dev mode for better performance
  23. output: {
  24. filename: '[name].js',
  25. chunkFilename: '[name].chunk.js'
  26. },
  27. optimization: {
  28. splitChunks: {
  29. // chunks: 'all',
  30. chunks: 'async',
  31. maxAsyncRequests: 5,
  32. cacheGroups: {
  33. vendors: {
  34. test: /[\\/]node_modules[\\/](?!antd|jquery|three|bootstrap-datepicker)(.[a-zA-Z0-9.\-_]+)[\\/]/,
  35. // test: /[\\/]node_modules[\\/]/,
  36. name: 'vendor',
  37. chunks: 'all'
  38. }
  39. }
  40. }
  41. },
  42. // Add development plugins
  43. plugins: [
  44. new webpack.HotModuleReplacementPlugin(), // Tell webpack we want hot reloading
  45. new HtmlWebpackPlugin({
  46. filename: 'index.html',
  47. chunks: ['app', 'app~share', 'vendor'],
  48. inject: true, // Inject all files that are generated by webpack, e.g. bundle.js
  49. template: 'app/index.html'
  50. }),
  51. new HtmlWebpackPlugin({
  52. filename: 'share.html',
  53. chunks: ['share', 'app~share', 'vendor'],
  54. inject: true, // Inject all files that are generated by webpack, e.g. bundle.js
  55. template: 'app/index.html'
  56. }),
  57. new CircularDependencyPlugin({
  58. exclude: /a\.js|node_modules/, // exclude node_modules
  59. failOnError: false // show a warning when there is a circular dependency
  60. }),
  61. new ForkTsCheckerWebpackPlugin()
  62. ],
  63. tsLoaders: [{
  64. loader: 'babel-loader',
  65. options: {
  66. plugins: ['react-hot-loader/babel']
  67. }
  68. }],
  69. // Emit a source map for easier debugging
  70. // See https://webpack.js.org/configuration/devtool/#devtool
  71. devtool: 'eval-source-map',
  72. performance: {
  73. hints: false
  74. },
  75. htmlWebpackPlugin: {
  76. files: {
  77. js: ['app.js', 'share.js'],
  78. chunks: {
  79. app: {
  80. entry: 'app.js'
  81. },
  82. share: {
  83. entry: 'share.js'
  84. }
  85. }
  86. }
  87. }
  88. })