webpack.config.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. const path = require('path');
  2. const MiniCssExtractPlugin = require('mini-css-extract-plugin');
  3. const resolve = (url) => path.resolve(__dirname, "..", url);
  4. module.exports = {
  5. entry: {
  6. 'sheet-format': resolve("src/index.ts"),
  7. },
  8. module: {
  9. rules: [
  10. {
  11. test: /\.tsx?$/,
  12. use: [
  13. {
  14. loader: 'babel-loader',
  15. options: {
  16. cacheDirectory: true,
  17. },
  18. },
  19. {
  20. loader: 'ts-loader'
  21. }
  22. ]
  23. },
  24. {
  25. test: /\.css$/,
  26. use: [
  27. {
  28. loader: MiniCssExtractPlugin.loader,
  29. options: {
  30. publicPath: '../',
  31. },
  32. },
  33. {
  34. loader: 'css-loader',
  35. },
  36. ],
  37. },
  38. {
  39. test: /\.less$/,
  40. use: [
  41. {
  42. loader: MiniCssExtractPlugin.loader,
  43. options: {
  44. publicPath: '../',
  45. },
  46. },
  47. {
  48. loader: 'css-loader',
  49. },
  50. {
  51. loader: 'less-loader',
  52. },
  53. ],
  54. },
  55. {
  56. test: /\.(png|svg|jpe?g|gif)$/i,
  57. use: [
  58. {
  59. loader: 'url-loader',
  60. options: {
  61. limit: 18192,
  62. outputPath: 'img',
  63. name: '[name].[ext]?[hash]',
  64. esModule: false,
  65. },
  66. },
  67. ],
  68. },
  69. {
  70. test: /\.(woff|woff2|eot|ttf|otf)$/i,
  71. use: [
  72. {
  73. loader: 'file-loader',
  74. options: {
  75. outputPath: 'font',
  76. esModule: false,
  77. },
  78. },
  79. ],
  80. },
  81. {
  82. test: /\.wasm$/,
  83. type: 'webassembly/async',
  84. },
  85. ],
  86. },
  87. resolve: {
  88. extensions: ['.ts', '.tsx', '.js', '.json'],
  89. alias: {
  90. '@': resolve('src'),
  91. },
  92. },
  93. experiments: {
  94. syncWebAssembly: true,
  95. asyncWebAssembly: true,
  96. topLevelAwait: true,
  97. }
  98. };