webpack.dev.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. // Path where bundled files will be output
  34. path: path.resolve(__dirname, './static'),
  35. pathinfo: false,
  36. filename: '[name].bundle.js'
  37. },
  38. devServer: {
  39. contentBase: path.resolve(__dirname, './static'),
  40. hot: false,
  41. host: '0.0.0.0',
  42. port: env.HTTP_PORT || 8080
  43. },
  44. module: {
  45. rules: [
  46. // Load css files which will be injected in html page at startup <style>...</style>)
  47. {
  48. test: /\.css$/,
  49. use: ['style-loader', 'css-loader']
  50. },
  51. {
  52. test: /\.(woff(2)?|ttf|eot)(\?v=\d+\.\d+\.\d+)?$/,
  53. use: [{
  54. loader: 'file-loader',
  55. options: {
  56. name: '[name].[ext]',
  57. outputPath: 'fonts/'
  58. }
  59. }]
  60. },
  61. // Load angularJS partials HTML file as URL
  62. {
  63. test: /\.html$/,
  64. exclude: path.resolve(__dirname, './src/index.html'),
  65. use: [
  66. 'ng-cache-loader?prefix=[dir]/[dir]',
  67. 'extract-loader',
  68. 'html-loader'
  69. ]
  70. },
  71. // Load images as URLs
  72. {
  73. test: /\.(png|svg|jpg|gif)$/,
  74. use: {
  75. loader: 'file-loader',
  76. options: {
  77. name: '[name].[ext]',
  78. outputPath: 'images'
  79. }
  80. }
  81. },
  82. // Load locales files
  83. {
  84. type: 'javascript/auto',
  85. test: /\.json$/,
  86. include: path.resolve(__dirname, './src/assets/locales'),
  87. use: [
  88. {
  89. loader: 'file-loader',
  90. options: {
  91. name: '[name].[ext]',
  92. outputPath: 'locales'
  93. }
  94. }
  95. ]
  96. }
  97. ]
  98. }
  99. });