webpack.config.dev.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. const path = require('path');
  2. const webpack = require('webpack');
  3. module.exports = {
  4. name: 'ui',
  5. mode: 'development',
  6. devtool: 'cheap-module-eval-source-map',
  7. entry: [
  8. 'webpack-hot-middleware/client?name=ui&path=/__webpack_hmr',
  9. path.resolve(__dirname, 'src'),
  10. ],
  11. output: {
  12. path: path.resolve(__dirname, 'src'),
  13. filename: 'webviewer-ui.min.js',
  14. chunkFilename: 'chunks/[name].chunk.js',
  15. publicPath: '/',
  16. },
  17. plugins: [new webpack.HotModuleReplacementPlugin()],
  18. module: {
  19. rules: [
  20. {
  21. test: /\.js$/,
  22. use: {
  23. loader: 'babel-loader',
  24. options: {
  25. presets: [
  26. '@babel/preset-react',
  27. [
  28. '@babel/preset-env',
  29. {
  30. useBuiltIns: 'entry',
  31. corejs: 3,
  32. },
  33. ],
  34. ],
  35. plugins: [
  36. 'react-hot-loader/babel',
  37. '@babel/plugin-proposal-function-sent',
  38. '@babel/plugin-proposal-export-namespace-from',
  39. '@babel/plugin-proposal-numeric-separator',
  40. '@babel/plugin-proposal-throw-expressions',
  41. '@babel/plugin-proposal-class-properties',
  42. '@babel/plugin-proposal-optional-chaining',
  43. ],
  44. },
  45. },
  46. include: [path.resolve(__dirname, 'src')],
  47. },
  48. {
  49. test: /\.scss$/,
  50. use: [
  51. 'style-loader',
  52. 'css-loader',
  53. {
  54. loader: 'postcss-loader',
  55. options: {
  56. ident: 'postcss',
  57. plugins: loader => [
  58. require('postcss-import')({ root: loader.resourcePath }),
  59. require('postcss-preset-env')(),
  60. require('cssnano')(),
  61. ],
  62. },
  63. },
  64. 'sass-loader',
  65. ],
  66. include: path.resolve(__dirname, 'src'),
  67. },
  68. {
  69. test: /\.svg$/,
  70. use: ['svg-inline-loader'],
  71. },
  72. {
  73. test: /\.woff(2)?$/,
  74. use: [
  75. {
  76. loader: 'file-loader',
  77. options: {
  78. name: '[name].[ext]',
  79. },
  80. },
  81. ],
  82. },
  83. ],
  84. },
  85. resolve: {
  86. alias: {
  87. src: path.resolve(__dirname, 'src/'),
  88. components: path.resolve(__dirname, 'src/components/'),
  89. constants: path.resolve(__dirname, 'src/constants/'),
  90. helpers: path.resolve(__dirname, 'src/helpers/'),
  91. hooks: path.resolve(__dirname, 'src/hooks/'),
  92. actions: path.resolve(__dirname, 'src/redux/actions/'),
  93. reducers: path.resolve(__dirname, 'src/redux/reducers/'),
  94. selectors: path.resolve(__dirname, 'src/redux/selectors/'),
  95. core: path.resolve(__dirname, 'src/core/'),
  96. },
  97. }
  98. };