webpack.base.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. var path = require('path');
  2. const { VueLoaderPlugin } = require('vue-loader');
  3. const ESLintPlugin = require('eslint-webpack-plugin');
  4. const MiniCssExtractPlugin = require('mini-css-extract-plugin');
  5. module.exports = {
  6. module: {
  7. rules: [
  8. {
  9. test: /\.vue$/,
  10. loader: 'vue-loader',
  11. },
  12. {
  13. test: /\.js$/,
  14. loader: 'babel-loader',
  15. // include: [
  16. // path.resolve(__dirname, './node_modules/pc-component-v3/dist/pc-component-v3.js'),
  17. // ],
  18. exclude: /node_modules/,
  19. // exclude: file => (
  20. // /node_modules/.test(file) &&
  21. // !/\.vue\.js/.test(file)
  22. // ),
  23. },
  24. {
  25. test: /\.css$/,
  26. use: (process.env.NODE_ENV === 'production') ? [
  27. {
  28. loader: MiniCssExtractPlugin.loader,
  29. options: {
  30. publicPath: '../',
  31. },
  32. },
  33. 'css-loader'] : ['style-loader', 'css-loader'],
  34. },
  35. {
  36. test: /\.(json5?|ya?ml)$/, // target json, json5, yaml and yml files
  37. type: 'javascript/auto',
  38. loader: '@intlify/vue-i18n-loader',
  39. },
  40. {
  41. // webpack5 通过资源模块来处理图片
  42. test: /\.(png|jpg|gif|svg)$/,
  43. type: 'asset/resource',
  44. parser: {
  45. dataUrlCondition: {
  46. maxSize: 10240,
  47. },
  48. },
  49. generator: {
  50. filename: './client-eam-v5-image/[name][ext][query]',
  51. },
  52. },
  53. {
  54. test: /\.(eot|woff|woff2|ttf)$/,
  55. type: 'asset/resource',
  56. generator: {
  57. filename: './client-eam-v5-font/[name].[ext]?[hash]',
  58. },
  59. },
  60. ],
  61. },
  62. resolve: {
  63. alias: {
  64. },
  65. extensions: ['*', '.js', '.vue', '.json'],
  66. },
  67. performance: {
  68. hints: false,
  69. },
  70. externals: {
  71. 'jquery': "window.jquery",
  72. 'bootstrap': 'bootstrap',
  73. 'BootstrapDialog': 'BootstrapDialog',
  74. 'dayjs': 'dayjs',
  75. 'vue': 'Vue',
  76. 'vue-i18n': 'VueI18n',
  77. 'vue-router': 'VueRouter',
  78. 'vuex': 'Vuex',
  79. },
  80. plugins: [
  81. new VueLoaderPlugin(),
  82. new ESLintPlugin({
  83. extensions: ['js', 'vue'],
  84. // 自动修复。
  85. // 自从eslint推出--fix命令后,如果觉得eslint格式化规则已经够用的话,其实也可以不用prettier了。
  86. fix: true,
  87. }),
  88. ],
  89. };