webpack.dev.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /**
  2. * Webpack development configuration (merged with common one).
  3. * it overrides the webpack.common.js configuration and:
  4. * - Set mode to development -> This mode is used by some plugins and webpack to prevent minifying assets etc...
  5. * - Generates a sourcemap of bundled code -> Allow to easily debug js code (do not use in prod)
  6. * - Remove some bundling optimization to speed it up
  7. * - Allow Load css files (import './myCssFile.css') -> Css rules will be automatically added to index.html into a <style></style> tag.
  8. * - Allow to load fonts and images (import './myFont.eot'; import './someImage.jpg')
  9. */
  10. const merge = require('webpack-merge');
  11. const common = require('./webpack.common');
  12. const path = require('path');
  13. const env = process.env;
  14. module.exports = merge(common, {
  15. mode: 'development',
  16. devtool: 'cheap-eval-source-map',
  17. watchOptions: {
  18. aggregateTimeout: 300,
  19. poll: 1000
  20. },
  21. resolve: {
  22. symlinks: true
  23. },
  24. optimization: {
  25. // see https://webpack.js.org/guides/build-performance#avoid-extra-optimization-steps
  26. removeAvailableModules: false,
  27. removeEmptyChunks: false,
  28. // In dev mode we simply want to get a big bundle containing all our js
  29. splitChunks: false
  30. },
  31. output: {
  32. // see https://webpack.js.org/guides/build-performance#output-without-path-info
  33. pathinfo: false,
  34. filename: '[name].bundle.js'
  35. },
  36. devServer: {
  37. contentBase: './static',
  38. hot: false,
  39. host: '0.0.0.0',
  40. port: env.HTTP_PORT || 8082
  41. },
  42. module: {
  43. rules: [
  44. // Load css files which will be injected in html page at startup <style>...</style>)
  45. {
  46. test: /\.css$/,
  47. use: ['style-loader', 'css-loader']
  48. },
  49. {
  50. test: /\.(woff(2)?|ttf|eot)(\?v=\d+\.\d+\.\d+)?$/,
  51. use: [{
  52. loader: 'file-loader',
  53. options: {
  54. name: '[name].[ext]',
  55. outputPath: 'fonts/'
  56. }
  57. }]
  58. },
  59. // Load angularJS partials HTML file as URL
  60. {
  61. test: /\.html$/,
  62. exclude: path.resolve(__dirname, './src/index.html'),
  63. use: [
  64. 'ng-cache-loader?prefix=[dir]/[dir]',
  65. 'extract-loader',
  66. 'html-loader'
  67. ]
  68. },
  69. // Load images as URLs
  70. {
  71. test: /\.(png|svg|jpg|gif)$/,
  72. use: {
  73. loader: 'file-loader',
  74. options: {
  75. name: '[name].[ext]',
  76. outputPath: 'images'
  77. }
  78. }
  79. },
  80. // Load locales files
  81. {
  82. type: 'javascript/auto',
  83. test: /\.json$/,
  84. include: path.resolve(__dirname, './src/assets/locales'),
  85. use: [
  86. {
  87. loader: 'file-loader',
  88. options: {
  89. name: '[name].[ext]',
  90. outputPath: 'locales'
  91. }
  92. }
  93. ]
  94. }
  95. ]
  96. }
  97. });