webpack.config.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. const path = require('path')
  2. const webpack = require('webpack')
  3. const HtmlWebpackPlugin = require('html-webpack-plugin')
  4. const isDev = process.env.NODE_ENV === 'development'
  5. module.exports = {
  6. resolve: {
  7. extensions: ['.ts', '.tsx', '.js', '.json'],
  8. },
  9. module: {
  10. rules: [
  11. {
  12. test: /\.(ts|js)x?$/,
  13. use: [
  14. {
  15. loader: 'babel-loader',
  16. options: {
  17. cacheDirectory: true,
  18. cacheCompression: false,
  19. compact: !isDev,
  20. },
  21. },
  22. ],
  23. // exclude: path.resolve(__dirname, '../node_modules'),
  24. },
  25. {
  26. test: /\.(png|jpg|gif)$/i,
  27. use: [
  28. {
  29. loader: 'url-loader',
  30. options: {
  31. limit: 10000,
  32. name: 'static/media/[name].[hash:8].[ext]',
  33. },
  34. },
  35. ],
  36. exclude: path.resolve(__dirname, '../node_modules'),
  37. },
  38. {
  39. test: /\.(woff|woff2|eot|ttf|otf)$/,
  40. use: ['file-loader'],
  41. exclude: path.resolve(__dirname, '../node_modules'),
  42. },
  43. {
  44. test: /\.(rar|doc)$/,
  45. use: [
  46. {
  47. loader: 'file-loader',
  48. options: {
  49. name: 'static/assets/[name].[ext]',
  50. },
  51. },
  52. ],
  53. exclude: path.resolve(__dirname, '../node_modules'),
  54. },
  55. ],
  56. },
  57. plugins: [
  58. new webpack.NamedModulesPlugin(),
  59. new webpack.BannerPlugin('nick 291375086@qq.com'),
  60. new HtmlWebpackPlugin({
  61. template: path.resolve(__dirname, './index.html'),
  62. title: '智慧工地-供应商平台',
  63. filename: 'index.html',
  64. chunks: ['index'],
  65. }),
  66. new HtmlWebpackPlugin({
  67. template: path.resolve(__dirname, './index.html'),
  68. title: '供应商公示',
  69. filename: 'publicity.html',
  70. chunks: ['publicity'],
  71. }),
  72. ],
  73. }