webpack.common.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. const { HTMLWebpackPlugins, entry } = require('./_build/genMultiEntry.js')
  2. const VueLoaderPlugin = require('vue-loader/lib/plugin')
  3. const path = require('path')
  4. module.exports = {
  5. entry: entry,
  6. output: {
  7. chunkFilename: 'js/[name]_[contenthash:5].js'
  8. },
  9. resolve: {
  10. extensions:['.js', '.vue'],
  11. alias: {
  12. '@': path.resolve(__dirname, 'src')
  13. }
  14. },
  15. optimization: {
  16. splitChunks: {
  17. chunks: 'all'
  18. }
  19. },
  20. module: {
  21. rules: [
  22. {
  23. test: /\.js$/,
  24. exclude: /node_modules|dwudbproxy\.js/,
  25. use: [
  26. 'babel-loader',
  27. {
  28. loader: 'eslint-loader',
  29. options: {
  30. fix: true
  31. }
  32. }
  33. ]
  34. },
  35. {
  36. test: /\.vue$/,
  37. loader: 'vue-loader'
  38. },
  39. {
  40. test: /\.html$/,
  41. use: {
  42. loader: 'html-loader',
  43. options: {
  44. attrs: [':src']
  45. }
  46. }
  47. },
  48. {
  49. test: /\.(svg|jpe?g|gif|png|bmp)$/,
  50. use: {
  51. loader: 'url-loader',
  52. options: {
  53. name: '[name]_[hash:5].[ext]',
  54. outputPath: 'images',
  55. limit: 2048
  56. }
  57. }
  58. },
  59. {
  60. test: /\.(eot|ttf|woff2?|otf)$/,
  61. use: {
  62. loader: 'file-loader',
  63. options: {
  64. name: '[name]_[hash:5].[ext]',
  65. outputPath: 'fonts'
  66. }
  67. }
  68. }
  69. ]
  70. },
  71. plugins: [
  72. ...HTMLWebpackPlugins,
  73. new VueLoaderPlugin()
  74. ]
  75. }