webpack.client.config.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. const path = require('path');
  2. const MiniCssExtractPlugin = require('mini-css-extract-plugin');
  3. const ESLintPlugin = require('eslint-webpack-plugin');
  4. const ProgressBarWebpackPlugin = require('progress-bar-webpack-plugin');
  5. const resolve = (url) => path.resolve(__dirname, '..', url);
  6. module.exports = {
  7. mode: 'development',
  8. devtool: 'source-map',
  9. entry: {
  10. client: resolve("src/client.ts"),
  11. },
  12. module: {
  13. rules: [
  14. {
  15. test: /\.tsx?$/,
  16. use: [
  17. {
  18. loader: 'babel-loader',
  19. options: {
  20. cacheDirectory: true,
  21. },
  22. },
  23. {
  24. loader: 'ts-loader',
  25. },
  26. ],
  27. },
  28. {
  29. test: /\.css$/,
  30. use: [
  31. {
  32. loader: MiniCssExtractPlugin.loader,
  33. options: {
  34. publicPath: '../',
  35. },
  36. },
  37. {
  38. loader: 'css-loader',
  39. },
  40. ],
  41. },
  42. {
  43. test: /\.less$/,
  44. use: [
  45. {
  46. loader: MiniCssExtractPlugin.loader,
  47. options: {
  48. publicPath: '../',
  49. },
  50. },
  51. {
  52. loader: 'css-loader',
  53. },
  54. {
  55. loader: 'less-loader',
  56. },
  57. ],
  58. },
  59. {
  60. test: /\.(png|svg|jpe?g|gif)$/i,
  61. use: [
  62. {
  63. loader: 'url-loader',
  64. options: {
  65. limit: 18192,
  66. outputPath: 'img',
  67. name: '[name].[ext]?[hash]',
  68. esModule: false,
  69. },
  70. },
  71. ],
  72. },
  73. {
  74. test: /\.(woff|woff2|eot|ttf|otf)$/i,
  75. use: [
  76. {
  77. loader: 'file-loader',
  78. options: {
  79. outputPath: 'font',
  80. esModule: false,
  81. },
  82. },
  83. ],
  84. },
  85. {
  86. test: /\.wasm$/,
  87. type: 'webassembly/async',
  88. },
  89. ],
  90. },
  91. resolve: {
  92. extensions: ['.ts', '.tsx', '.js', '.json'],
  93. alias: {
  94. '@': resolve('src'),
  95. },
  96. },
  97. experiments: {
  98. syncWebAssembly: true,
  99. asyncWebAssembly: true,
  100. topLevelAwait: true,
  101. },
  102. plugins: [
  103. new ESLintPlugin({
  104. overrideConfigFile: resolve(".eslintrc.js"),
  105. context: resolve("src"),
  106. extensions: ['ts', 'js'],
  107. fix: true,
  108. }),
  109. new ProgressBarWebpackPlugin(),
  110. ],
  111. target: 'web',
  112. output: {
  113. filename: 'js/[name].js',
  114. libraryTarget: 'umd',
  115. library: 'Web',
  116. path: resolve('dist'),
  117. },
  118. };